Looking for some guidance as I'm stuck on my next steps...
My goal is to create a listener on a single project and when the "T-Shirt" custom field is set or modified (values are "S", "M", "L") we update the original estimate field with a corresponding value.
Small = 5d
Medium = 10d
Large = 15d
I've added a post function to test on new issue creation to set an original estimate, but still nothing is set (currently just testing the "M" size).
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tshirt = customFieldManager.getCustomFieldObject(10142)
def tshirtsize = issue.getCustomFieldValue(tshirt)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false);
2019-12-10 00:18:42,530 DEBUG [workflow.ScriptWorkflowFunction]: T-Shirt 2019-12-10 00:18:42,530 DEBUG [workflow.ScriptWorkflowFunction]: M
Debug logs are showing the custom field and it's value correctly, so it's how I'm setting the original estimate field. Any help would be greatly appreciated.
It is the "if" statement that is checking if the selection is M.
Select lists hold "options", not strings, so "if ( <option that is labelled as M> == 'M' )" is going to return a false.
I would usually do it this way:
if ( "M".equals(tshirtsize.getName() ) )
(I've had defensive coding kicked into me, and the use of .equals rather than == as it's safer for strings)
Thank you very much for your response @nic .
I tried to update the script with your suggestion and using import com.atlassian.jira.issue.fields per the API documentation (https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/issue/fields/Field.html#getName--) but it's still cannot find the matching method for tshirtsize.getname().
Can you point me in the right direction?
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events