Automation to append the dropdown select list Options based on Customer Input
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
In this article, we cover a scenario where a JSM Customer fills out a Text Field from the customer portal.
Jira Automation adds this field value to a Custom Drop-down Select List field in the Jira work item view for JSM agents to use.
Solution
Get field value with REST API
Since we're moving from a text field to a select list field, we'll actually be adding the text field value as a list option on the select field.
First, we need the select field context ID, which we can use to update that field's options.
API Calls to Get the Context of the Custom Field ID:Get Field Context
API Call to update the Options in the DropDown Field:Update the Options
Use the steps below to configure a rule.
Part 1: Create an API Key for your admin account
Log in to https://id.atlassian.com/manage-profile/security/api-tokens
Select Create API token
From the dialog that appears, enter a Label for your token and select Create
Copy the token to clipboard, then paste the token elsewhere to save
Encode the API token as outlined in our documentation: https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/
Part 2: Capture HTTP Response of adding the Option
In this rule, the WebRequest attempts to add a new option value to the Select List field.
If the option value(s) already exist, the webResponse.Status would be a failure, and the Automation Rule will proceed to the next step.
Go to Project Settings > Automation > Create Rule
Choose either one of the Automated Triggers or use a Manual Trigger
For the purpose of this example, we will use the Work item Created trigger
Add a Send Web request action:
Web request URL: https://your-domain.atlassian.net/rest/api/3/field/{fieldId}/context/{contextId}/option
Headers:
Authorization: Basic <encoded-api-key-from-above>
X-ExperimentalAPI: opt-in
HTTP Method: POST
Body: Custom data:
{ "options": [ { "disabled": false, "value": "{{customfield_XXXXX}}" } ] }
Enable"Delay execution of subsequent rule actions until we've received a response for this web request
Enable "Continue running the rule even if the request response is not successful (i.e. non-200 response)
Add comment and/or log action to capture STATUS from the Web Response: {{webResponse.Status}}
Add a Re-fetch work item action to ensure that once the option value(s) are added above, we get the updated dropdown list
Part 3: Edit the Drop Down Field with the Option Value
The next part of the rule will select the Option value in the Jira work item view.
After the Re-fetch work item action, add an Edit work item action
Select the name of the Drop-Down field you want to edit and add the smart value of the Text Field: customfield_XXXXX
Was this helpful?