The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Custom Field : Amount
If Amount >= $1000 Then Approver = John
If Amount < $1000 Then Approver = Jill
Trying to get this into my workflow. Any suggestions?
Thanks.
Hi Michael,
Assuming your 'Amount' field ID is 11111 and your 'Approver' field ID is 22222, your script should look something like this:
import com.atlassian.jira.component.ComponentAccessor
def usrMgr = ComponentAccessor.getUserManager()
def cfMgr = ComponentAccessor.getCustomFieldManager()
def amount = cfMgr.getCustomFieldObject(11111.toLong())
def approver = cfMgr.getCustomFieldObject(22222.toLong())
def userJohn = usrMgr.getUserByName("John's user name")
def userJill = usrMgr.getUserByName("Jill's user name")
if (issue.getCustomFieldValue(amount) >= 1000){
issue.setCustomFieldValue(approver, userJohn)
}else if (issue.getCustomFieldValue(amount) < 1000){
issue.setCustomFieldValue(approver, userJill)
}
Is there documentation somewhere on how I should properly test this? Can I do it from the ScriptRunner console or do I have to do it from an actual issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In my instance I have a test project to play around with safely.
I suppose you can also do it in ScriptRunner console on a dummy issue, but you'll need to declare your 'issue' variable for that:
def issue = ComponentAccessor.getIssueManager().getIssueObject("test issue key")
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gives me unable to resolve class com.atlassian.jira.component.componentAccessor.
I am using Jira Cloud if that matters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it should be exactly like this (case sensitive):
import com.atlassian.jira.component.ComponentAccessor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is exactly like that.
Workflow Post Functions | Run Script | Run arbitrary code on transition
and then I copied the code to the Script Context section
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi , how to add more than one approver in list based on condition, Please help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity. Atlassian:...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.