Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Change radio button value in transition function with script

Pascal Laub September 6, 2019 edited

Hello,

I read so many threads here but couldn't solve mine.

I have a workflow which determines the next status by the option which is set as a radio button, e.g.:

This issue needs accounting? * Yes * No
And there are transitions who have conditions based on $accounting.getValue().

In the transition from accounting back to the "In Progress" status it should alter the radio button for needs accounting from Yes to No.

But I get an Unknown Error ("You tried running an illegitimate function ...").

This is the code (I'm Using CodeRunner):

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Logger log = LoggerFactory.getLogger(this.getClass());
def changeHolder = new DefaultIssueChangeHolder();
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def customField = customFieldManager.getCustomFieldObjectByName("Abrechnung erforderlich?");
def cfConfig = customField.getRelevantConfig($issue);
def optionFalse = ComponentAccessor.optionsManager.getOptions(cfConfig).getOptionForValue("Nein", null);
def optionTrue = ComponentAccessor.optionsManager.getOptions(cfConfig).getOptionForValue("Ja", null);
log.warn("Updating Value...");
customField.updateValue(null, $issue, new ModifiedValue(optionTrue, optionFalse), changeHolder);

 

The Log:

2019-09-06 19:20:47,526 http-nio-8080-exec-22 WARN rpl 1160x186790x1 1cd7crn 84.63.242.152 /secure/WorkflowUIDispatcher.jspa [script156779044535638652203] Updating Value...
2019-09-06 19:20:47,564 http-nio-8080-exec-22 ERROR rpl 1160x186790x1 1cd7crn 84.63.242.152 /secure/WorkflowUIDispatcher.jspa [c.a.jira.workflow.OSWorkflowManager] Caught exception while attempting to perform action 171 from workflow 14105 on issue 'MAGNUS-5'
java.lang.NullPointerException
at fr.gfi.jira.plugins.runner.workflow.GroovyPostFunction.execute(GroovyPostFunction.java:46)
at com.opensymphony.workflow.AbstractWorkflow.executeFunction(AbstractWorkflow.java:1014)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1407)
at com.opensymphony.workflow.AbstractWorkflow.doAction(AbstractWorkflow.java:557)
at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowActionInsideTxn(OSWorkflowManager.java:830)
at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowAction(OSWorkflowManager.java:787)
at com.atlassian.jira.bc.issue.DefaultIssueService.transition(DefaultIssueService.java:510)
at com.atlassian.jira.web.action.workflow.SimpleWorkflowAction.doExecute(SimpleWorkflowAction.java:28)
... 1 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
... 48 filtered
at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:62)
... 12 filtered
at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
... 62 filtered
at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66)
... 1 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64)
... 39 filtered
at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
... 10 filtered
at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
... 4 filtered
at com.atlassian.web.servlet.plugin.LocationCleanerFilter.doFilter(LocationCleanerFilter.java:36)
... 26 filtered
at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
... 25 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

 

I also tried to alter the order of the transition tasks, so that this is done as last (after create). But that didn't help either...

 

Does one of you have another idea I can try?

 

I'm using CodeRunner plugin (not ScriptRunner) and Jira Server v8.1.0

1 answer

1 accepted

0 votes
Answer accepted
Pascal Laub September 6, 2019

Okay, nvm... I installed ScriptRunner and it works.... Then it has to be a problem with CodeRunner

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events