Snippets

Adaptavist Script Console Set Multi User Picker Field

Updated by Kristian Walker

File ScriptConsoleSetMultiSelectListField.groovy Modified

  • Ignore whitespace
  • Hide word diff
 /*
-* This example script  console script updates a multi select list field on an issue.
+* This example script  console script updates a multi user picker field on an issue.
 * "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." 
 def issue = "<issueKeyHere>"
 
 // Specify the ID of the custcom field here
-def MultiSelectField = "<CustomFieldIdHere>".toString()
+def MultiUserField = "<CustomFieldIdHere>".toString()
 
 
 // The rest call to update the multi user picker field. 
             // Specify the update structure to update the Multi Select list field and its Array List Data Structure that it uses
             update:
                 [
-                    (MultiSelectField): [
+                    (MultiUserField): [
                         // Specify the add commands to add each user into the Array List structure for the field using their accountId
                         // Comma seperate the add commend for each user you want to add using their accountId
                         [add: [accountId: "<AccountIDHere>"]],
Created by Kristian Walker

File ScriptConsoleSetMultiSelectListField.groovy Added

  • Ignore whitespace
  • Hide word diff
+/*
+* This example script  console script updates a multi select list field on an issue.
+* "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." 
+*/
+
+// Specify the issue key of the issue to update below
+def issue = "<issueKeyHere>"
+
+// Specify the ID of the custcom field here
+def MultiSelectField = "<CustomFieldIdHere>".toString()
+
+
+// The rest call to update the multi user picker field. 
+// Note: This script must be run as the ScriptRunner add on user
+def setMultiUserPicker = put("/rest/api/2/issue/"+ issue)
+        .header('Content-Type', 'application/json')
+        .queryString("overrideScreenSecurity", Boolean.TRUE)
+        .body([
+            // Specify the update structure to update the Multi Select list field and its Array List Data Structure that it uses
+            update:
+                [
+                    (MultiSelectField): [
+                        // Specify the add commands to add each user into the Array List structure for the field using their accountId
+                        // Comma seperate the add commend for each user you want to add using their accountId
+                        [add: [accountId: "<AccountIDHere>"]],
+                        [add: [accountId: "<AccountIDHere>"]]
+                        ]
+                
+                ]
+        ])
+        .asString()
+        .body
+        
+return "Issue with the key of ${issue} updated with the Multi User Picker Field set on it"        
HTTPS SSH

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