Snippets

Adaptavist ScriptRunner for Jira Cloud Set Multi Select List Field

Updated by Kristian Walker

File SRCloudSetMultiSelectListField.groovy Modified

  • Ignore whitespace
  • Hide word diff
 
 // The rest call to update the multi user picker field. 
 // Note: This script must be run as the ScriptRunner add on user
-def setMultiSelectField = put("/rest/api/2/issue/"+ issue)
+def setMultiSelectField = 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 option into the multi select list field as a comma seperated list of the option values to be set.
-                        // Note these option values must be valid option values that can be selected on the edit issue form inside of Jira. 
-                        [add: [value: "<OptionValueHere>"]],
-                        [add: [value: "<OptionValueHere>"]]
-                        // If you want to remove an item then you would do it by adding a line similar to below
-                        //[remove: [value: "<OptionValueHere>"]]
+                // 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 option into the multi select list field as a comma seperated list of the option values to be set.
+                                        // Note these option values must be valid option values that can be selected on the edit issue form inside of Jira. 
+                                        [add: [value: "<OptionValueHere>"]],
+                                        [add: [value: "<OptionValueHere>"]]
+                                        // If you want to remove an item then you would do it by adding a line similar to below
+                                        //[remove: [value: "<OptionValueHere>"]]
+                                ]
+
                         ]
-                
-                ]
         ])
         .asString()
         .body
-        
- // Note if you are creating a new issue then you do not need the update property and the body to set the field would be similar to below
-        /*
-        .body(
-        [
-                fields: [
-                        customfield_10073: [ 
-                            [value: "A"],
-                            [value: "B"]
-                            ],
-                        // Rest of body here
-                ]
-        ])
-        .asString().body
-        */
-        
+
+// Note if you are creating a new issue then you do not need the update property and the body to set the field would be similar to below
+/*
+.body(
+[
+        fields: [
+                (MultiSelectField): [ 
+                    [value: "A"],
+                    [value: "B"]
+                    ],
+                // Rest of body here
+        ]
+])
+.asString().body
+*/
+
 return "Issue with the key of ${issue} updated with the Multi Select List Field set on it"        
Updated by Kristian Walker

File SRCloudSetMultiSelectListField.groovy Modified

  • Ignore whitespace
  • Hide word diff
         .header('Content-Type', 'application/json')
         .queryString("overrideScreenSecurity", Boolean.TRUE)
         
-        // Note if you are creating a new issue then you do not need the update property and the body to set the field would be similar to below
-        /*
-        .body(
-        [
-                fields: [
-                        customfield_10073: [ 
-                            [value: "A"],
-                            [value: "B"]
-                            ],
-                        // Rest of body here
-                ]
-        ])
-        .asString().body
-        */
         .body([
             // Specify the update structure to update the Multi Select list field and its Array List Data Structure that it uses
             update:
         .asString()
         .body
         
+ // Note if you are creating a new issue then you do not need the update property and the body to set the field would be similar to below
+        /*
+        .body(
+        [
+                fields: [
+                        customfield_10073: [ 
+                            [value: "A"],
+                            [value: "B"]
+                            ],
+                        // Rest of body here
+                ]
+        ])
+        .asString().body
+        */
+        
 return "Issue with the key of ${issue} updated with the Multi Select List Field set on it"        
Updated by Kristian Walker

File SRCloudSetMultiSelectListField.groovy Modified

  • Ignore whitespace
  • Hide word diff
 def setMultiSelectField = put("/rest/api/2/issue/"+ issue)
         .header('Content-Type', 'application/json')
         .queryString("overrideScreenSecurity", Boolean.TRUE)
+        
+        // Note if you are creating a new issue then you do not need the update property and the body to set the field would be similar to below
+        /*
+        .body(
+        [
+                fields: [
+                        customfield_10073: [ 
+                            [value: "A"],
+                            [value: "B"]
+                            ],
+                        // Rest of body here
+                ]
+        ])
+        .asString().body
+        */
         .body([
             // Specify the update structure to update the Multi Select list field and its Array List Data Structure that it uses
             update:
Updated by Kristian Walker

File SRCloudSetMultiSelectListField.groovy Modified

  • Ignore whitespace
  • Hide word diff
                         // Note these option values must be valid option values that can be selected on the edit issue form inside of Jira. 
                         [add: [value: "<OptionValueHere>"]],
                         [add: [value: "<OptionValueHere>"]]
+                        // If you want to remove an item then you would do it by adding a line similar to below
+                        //[remove: [value: "<OptionValueHere>"]]
                         ]
                 
                 ]
Updated by Kristian Walker

File SRCloudSetMultiSelectListField.groovy Modified

  • Ignore whitespace
  • Hide word diff
         .asString()
         .body
         
-return "Issue with the key of ${issue} updated with the Multi User Picker Field set on it"        
+return "Issue with the key of ${issue} updated with the Multi Select List Field set on it"        
  1. 1
  2. 2
HTTPS SSH

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