I need to change the status issue if component = " NEW URL" i'm using the code bellow and it don't work
import com.atlassian.jira.workflow.WorkflowTransitionUtil import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl import com.atlassian.jira.util.JiraUtils def currentComponents = issue.getComponents() def workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class ) workflowTransitionUtil.setIssue(issue) workflowTransitionUtil.setUserkey(currentUser.name) for (c in currentComponents) { if (c.getName() == "NEW URL") { workflowTransitionUtil.setAction(191) } else { workflowTransitionUtil.setAction(181) } } workflowTransitionUtil.validate() workflowTransitionUtil.progress()
What errors do you get in the logs? What does "it doesn't work" mean in detail?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"it does not work" is mostly useless as a problem report.
Imagine ringing a car mechanic and saying "I can't use my car". He needs to know roughly what is wrong with it so he can bring the right tools. "It does not work" could be a lost key, out of fuel, surrounded by a horde of angry penguins, in a ditch etc.
If your code is running and failing, there will be errors in the logs. But your "it does not work" does not tell us where it is supposed to be running, what triggers it, or what goes into the logs.
We can't help you unless you tell us what errors you get and what "it does not work" really means.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the Log
Time (on server): Mon Jun 12 2017 11:38:04 GMT+0100 (Afr. centrale Ouest) The following log information was produced by this execution. Use statements like:log.info("...") to record logging information. 2017-06-12 12:38:04,240 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2017-06-12 12:38:04,240 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script> java.lang.IllegalArgumentException: No workflow action with id '191' available for issue null at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.retrieveActionDescriptor(WorkflowTransitionUtilImpl.java:162) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.retrieveActionDescriptorWithPermissionCheck(WorkflowTransitionUtilImpl.java:146) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.getActionDescriptor(WorkflowTransitionUtilImpl.java:133) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.getFieldScreenRenderer(WorkflowTransitionUtilImpl.java:292) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.validateFieldsParams(WorkflowTransitionUtilImpl.java:255) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.access$500(WorkflowTransitionUtilImpl.java:37) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl$2.get(WorkflowTransitionUtilImpl.java:247) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl$2.get(WorkflowTransitionUtilImpl.java:236) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.impersonateUser(WorkflowTransitionUtilImpl.java:380) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.validate(WorkflowTransitionUtilImpl.java:236) at com.atlassian.jira.workflow.WorkflowTransitionUtil$validate$2.call(Unknown Source) at Script3708.run(Script3708.groovy:23)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This error you said you didn't have is very clear: "issue: null". This means what it says. Your script has no issue to work with.
Makes me think your script is being run in the wrong place.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Run the script in the right place, where it has an issue context?
It's not clear what you are trying to do, or how, or where you're running this script. You'll need to explain that if you need more help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I need To select the next status based on the component choose Exemple :
If Componenet == option 1
status == " Open "
Else
Status == " IN PROGRESS
do u inderstand me now ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I understand that, it's what your code tries to do, but you need to tell us where you want to do this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thank you for ur help but that's my question is where should I put the code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you seen, that i didn't get the code to work in the create transition, but that i found a different way to achieve your goal? I answered to your question you asked here on the same topic.
Its perhaps better to ask only once to avoid duplicates in answers.
https://community.atlassian.com/t5/Questions/Change-statut-based-on-Component-on-create/qaq-p/595739
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The location depends on when you want this to happen.
Do you need it as part of the workflow? If it's for a specific transition (e.g. move from open to in-progress), then you need to do it in a post-function
If you need to run it every time a field is changed, you need to do it in a listener.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, that's a post-function then, but because it's a change of status, it won't work.
You need to use an automatic transition, as the create issue process needs to finish before you start the next transition.
It looks like you are using "Script Runner", which does have a "fast track transition". Rather than try to write your own (which is, at best, "painful"), you really need to use that to do it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.