Hello all,
I am trying to set logic for executing a specific transition based on specific logic in an issue. The logic hat I am working with is as follows:
Now, when the issue is created, we take the attribute value of the Requestor and populate a custom field (single user picker), called GTRI Username with the user ID. We then want to send the request in 1 of 2 directions, based on certain criteria:
I have been trying to use the JMWE Transition post function and can get the group membership to work using:
(groupManager.getGroupNamesForUser(issue.reporter).contains("ESD Approval"))
But I cannot seem to get 2 critieria to work properly. So, I've been trying to use ScriptRunner's Fast-track transition an issue also, but have had no luck.
I was testing my code with the script console and it can get single scenarios to work, but can't get both so I need some help creating a script. I am open to:
Here is what I have come up with:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def groupManager = ComponentAccessor.getGroupManager()
def reporter = issue.reporter.displayName
def gtriReporterField = customFieldManager.getCustomFieldObject(12935L)
def gtriReporter = issue.getCustomFieldValue(gtriReporterField).displayName
If/Then statement -
if (groupManager.getGroupNamesForUser(issue.reporter).contains("ESD Approval")) && (gtriReporter == reporter) {
execute Transition B
}
execute Transition A
I understand the the if/then logic will not work, but wanted to show you all what I was trying.
Thanks in advance.
Hi Thomas,
I'm not sure what you mean by not being able to get 2 criteria to work properly using JMWE. I assume you were using a Conditional Execution script, and you can totally combine criteria using boolean logic ("||" for "or" and ”&&" for "and", etc.)
What you could do is use 2 Transition Issue post-functions, one for each possible transition to trigger, and use Conditional Execution to select the one that should run. The code will be much simpler than writing a full ScriptRunner script.
For example, testing whether the reporter and the requester are the same is as simple as:
issue.get("reporter") == issue.get("GTRI Username")
You can also request help from Innovalog support. See http://www.innovalog.com/support
As luck would have it, an Adaptavist associate was attending our AUG meeting yesterday and was nice enough to steer me in the right direction. I wasn't too far off either. Based on our conversation, I just needed to set the condition statement up like this:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def groupManager = ComponentAccessor.getGroupManager()
def reporter = issue.reporter.displayName
def gtriReporterField = customFieldManager.getCustomFieldObject(12935L)
def gtriReporter = issue.getCustomFieldValue(gtriReporterField).displayName
if (gtriReporter != reporter) {
if (groupManager.getGroupNamesForUser(issue.reporter).contains("ESD Approval")) {
return true;
}
}
return false;
This is working now! Thank you all for the assist on this.
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.