Snippets

Adaptavist Jira Cloud Set Assignee Based On A User Picker Field On Create Transition

Updated by Kristian Walker

File JiraCloudSetAssigneeBasedOnAUserPickerFieldOnCreateTransition.groovy Modified

  • Ignore whitespace
  • Hide word diff
         .header('Content-Type', 'application/json')
         .asObject(Map)
 
-// Get the accountID value from the Approver field
+// Get the accountID value from the custom user picker field
 def assigneeValue = result.body.fields.(customField.id).accountId
 
 //logger.info('Assignee Value is' + assigneeValue)
         .header('Content-Type', 'application/json')
         .body([
         fields:[
-                // Update the assignnee to the value of the approver field using the account ID so that the format is compliant with the upcoming GDPR changes.
+                // 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]
         ]
 ])
Updated by Kristian Walker

File JiraCloudSetAssigneeBasedOnAUserPickerFieldOnCreateTransition Deleted

  • Ignore whitespace
  • Hide word diff
-/*
- * "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 key
-def issue = issue.key
-
-// Specify the name of the  list field to set
-def userPickerFieldName = "<FieldNameHere>"
-
-// Get the Approver Custom field to get the option value from
-def customField = get("/rest/api/2/field")
-        .asObject(List)
-        .body
-        .find {
-            (it as Map).name == userPickerFieldName
-        } as Map
-        
-// Check if the custom field returns a valid field and is not null
-assert customField != null : "Cannot find custom field with name of: ${userPickerFieldName}"
-
-def result = get('/rest/api/2/issue/' + issue)
-        .header('Content-Type', 'application/json')
-        .asObject(Map)
-
-// Get the value from the Approver field
-def assigneeValue = result.body.fields.(customField.id).name
-
-//logger.info('Assignee Value is' + assigneeValue)
-
-def updateResult = put('/rest/api/2/issue/' + issue)
-        .header('Content-Type', 'application/json')
-        .body([
-        fields:[
-                // Update the assignnee to the value of the approver field
-                assignee:[name:assigneeValue]
-        ]
-])
-        .asString()

File JiraCloudSetAssigneeBasedOnAUserPickerFieldOnCreateTransition.groovy Added

  • Ignore whitespace
  • Hide word diff
+/*
+ * "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 key
+def issue = issue.key
+
+// Specify the name of the  list field to set
+def userPickerFieldName = "<UserPickerFieldNameHere>"
+
+// Get the Approver Custom field to get the option value from
+def customField = get("/rest/api/2/field")
+        .asObject(List)
+        .body
+        .find {
+            (it as Map).name == userPickerFieldName
+        } as Map
+        
+// Check if the custom field returns a valid field and is not null
+assert customField != null : "Cannot find custom field with name of: ${userPickerFieldName}"
+
+// Get the issue object to get the field value from
+def result = get('/rest/api/2/issue/' + issue)
+        .header('Content-Type', 'application/json')
+        .asObject(Map)
+
+// Get the accountID value from the Approver field
+def assigneeValue = result.body.fields.(customField.id).accountId
+
+//logger.info('Assignee Value is' + assigneeValue)
+
+def updateResult = put('/rest/api/2/issue/' + issue)
+        .header('Content-Type', 'application/json')
+        .body([
+        fields:[
+                // Update the assignnee to the value of the approver field using the account ID so that the format is compliant with the upcoming GDPR changes.
+                assignee:[id:assigneeValue]
+        ]
+])
+        .asString()
Updated by Kristian Walker

File JiraCloudSetAssigneeBasedOnAUserPickerFieldOnCreateTransition Modified

  • Ignore whitespace
  • Hide word diff
 /*
- * "These two lines of code can be added to the Additioanl Code box in the Clone an Issue Post Function on Jira Cloud to skip cloning either all attachments or some attachments
+ * "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." 
Created by Kristian Walker

File JiraCloudSetAssigneeBasedOnAUserPickerFieldOnCreateTransition Added

  • Ignore whitespace
  • Hide word diff
+/*
+ * "These two lines of code can be added to the Additioanl Code box in the Clone an Issue Post Function on Jira Cloud to skip cloning either all attachments or some attachments
+ * 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 key
+def issue = issue.key
+
+// Specify the name of the  list field to set
+def userPickerFieldName = "<FieldNameHere>"
+
+// Get the Approver Custom field to get the option value from
+def customField = get("/rest/api/2/field")
+        .asObject(List)
+        .body
+        .find {
+            (it as Map).name == userPickerFieldName
+        } as Map
+        
+// Check if the custom field returns a valid field and is not null
+assert customField != null : "Cannot find custom field with name of: ${userPickerFieldName}"
+
+def result = get('/rest/api/2/issue/' + issue)
+        .header('Content-Type', 'application/json')
+        .asObject(Map)
+
+// Get the value from the Approver field
+def assigneeValue = result.body.fields.(customField.id).name
+
+//logger.info('Assignee Value is' + assigneeValue)
+
+def updateResult = put('/rest/api/2/issue/' + issue)
+        .header('Content-Type', 'application/json')
+        .body([
+        fields:[
+                // Update the assignnee to the value of the approver field
+                assignee:[name:assigneeValue]
+        ]
+])
+        .asString()
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.