Forums

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

Workflow Path based on Select List

Jason J
Contributor
November 12, 2015

Hello,

I am trying to take a different workflow path based on a select list choice from the user.  Meaning if the user selects Yes it would take one workflow path, if the user selects No it would take another.

Any ideas?

Thanks for the help!

 

1 answer

0 votes
Fabio Racobaldo _Catworkx_
Community Champion
May 23, 2014

Hey Derryl,

try to use the following code :

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField severityCF = customFieldManager.getCustomFieldObjectByName("YOUR_CF_NAME_SEVERITY");
String severity = issue.getCustomFieldValue(severityCF)!=null?issue.getCustomFieldValue(severityCF).toString():"";
if("Major".equalsIgnoreCase(severity)){
	return "dlprodalert";
}
return "prodalertminor";

Fabio Racobaldo _Catworkx_
Community Champion
May 23, 2014

Please, change YOUR_CF_NAME_SEVERITY with your custom field name.

Hope this helps,

Fabio

Darryl Lee
Contributor
May 29, 2014

Hey Fabio -- thank you for the example. Unfortunately I'm still getting an error:

/secure/QuickCreateIssue.jspa [jmwe.plugins.functions.SetFieldValueFunction] Error while executing SetFieldValueFunction: groovy.lang.MissingMethodException: No signature of method: com.innovalog.jmwe.IssueProxy.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.CustomFieldImpl) values: [Severity]

I tested the script using Script Runner's console, and it worked like a charm:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;

// Added for testing in Script Runner Console
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.IssueManager;
IssueManager issueManager = ComponentManager.getInstance().getIssueManager();
Issue issue = issueManager.getIssueObject( "INC-996" );

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

CustomField severityCF = customFieldManager.getCustomFieldObjectByName( "Severity" );
String severity = issue.getCustomFieldValue(severityCF)!=null?issue.getCustomFieldValue(severityCF).toString():"";

if("Major".equalsIgnoreCase(severity)){
    return "dlprodalert";
}
return "prodalertminor";

I've tried various tweaks, but I just can't make any progress. Thanks again.

Darryl Lee
Contributor
May 29, 2014

Hey Fabio -- thank you for the example. Unfortunately I'm still getting an error:

/secure/QuickCreateIssue.jspa [jmwe.plugins.functions.SetFieldValueFunction] Error while executing SetFieldValueFunction: groovy.lang.MissingMethodException: No signature of method: com.innovalog.jmwe.IssueProxy.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.CustomFieldImpl) values: [Severity]

I tested the script using Script Runner's console, and it worked like a charm:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;

// Added for testing in Script Runner Console
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.IssueManager;
IssueManager issueManager = ComponentManager.getInstance().getIssueManager();
Issue issue = issueManager.getIssueObject( "INC-996" );

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

CustomField severityCF = customFieldManager.getCustomFieldObjectByName( "Severity" );
String severity = issue.getCustomFieldValue(severityCF)!=null?issue.getCustomFieldValue(severityCF).toString():"";

if("Major".equalsIgnoreCase(severity)){
    return "dlprodalert";
}
return "prodalertminor";

Thanks again!

Darryl Lee
Contributor
May 29, 2014

I was thinking maybe the script doesn't think Severity is set yet. Is this because I'm trying to do this as a Post Function on Create? I've set these Post Functions to run last, well after "Creates the issue originally." and "Fire a ProdAlert Created event that can be processed by the listeners."

Is the problem that this Post Function can't figure out the severity of the current issue after Create?

"The value of field ProdAlert Notification List of the current issue will be set to the result of a Groovy expression (replacing existing values)"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events