/* * "This script should be placed as the last post function in the create transition in order to set the assignee field to the value of a user picker field. * All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner * license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed * or amended and must be included in any circumstances where the code snippet is shared by You or a third party." *///get the issue keydefissue=issue.key// Specify the name of the list field to setdefuserPickerFieldName="<UserPickerFieldNameHere>"// Get the Approver Custom field to get the option value fromdefcustomField=get("/rest/api/2/field").asObject(List).body.find{(itasMap).name==userPickerFieldName}asMap// Check if the custom field returns a valid field and is not nullassertcustomField!=null:"Cannot find custom field with name of: ${userPickerFieldName}"// Get the issue object to get the field value fromdefresult=get('/rest/api/2/issue/'+issue).header('Content-Type','application/json').asObject(Map)// Get the accountID value from the custom user picker fielddefassigneeValue=result.body.fields.(customField.id).accountId//logger.info('Assignee Value is' + assigneeValue)defupdateResult=put('/rest/api/2/issue/'+issue).header('Content-Type','application/json').body([fields:[// Update the assignnee to the value of the custom user picker field. We are using the account ID so that the format is compliant with the upcoming GDPR changes.assignee:[id:assigneeValue]]]).asString()
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.