Automation to append the dropdown select list Options based on Customer Input
Summary
This article delineates the procedure to capture the options value a designated text field, followed by the subsequent action of transferring these options to populate another dropdown select list field.
Environment
Jira Service Management Cloud
Jira Cloud
Diagnosis
Here in this article, we take a scenario where the JSM Customer fills out a Text Field from a customer portal, and Jira Automation adds this value to a Custom Drop Down Select List field to be used in Jira Issue View
Solution
We will use Rest API to add the options to a select list drop-down field.
- 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
Step 1: Create an API Key for your admin account
- Log in to https://id.atlassian.com/manage-profile/security/api-tokens.
- Click Create API token.
- From the dialog that appears, enter a memorable and concise Label for your token and click Create.
- Click Copy to clipboard, then paste the token elsewhere to save.
Step 2 : Capture HTTP Response of adding the Option
Go to Project Settings > Automation > Create Rule
One could either configure an Automated Trigger or have a Manual Trigger; as stated in Jira automation triggers, for the purpose of this example we will use a when Issue Created.
Select "Send Web Request " under "Add an Action"
Web Request URL https://your-domain.atlassian.net/rest/api/3/field/{fieldId}/context/{contextId}/option
Headers ( Optional )Authorization
Basic <Base64-ApiKey>
X-ExperimentalAPI opt-in BASE64 encode the string on a Linux/Unix/MacOS:
echo -n user@example.com:api_token_string | base64
- HTTP Method: POST
- 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 comments/log action to capture STATUS from the Web Response: {{webResponse.Status}}
Here the WebRequest will try to add a option values, if the option values already exist the webResponse.Status would be a failure and then the Automation Rule will proceed to the next step.
- Add a "Re-fetch issue" Action to ensure that once the option value are added above, we get the updated dropdown list.
The above operations will add the option value to select field if the option does not exist
Step 3 : Edit the Drop Down Field with the Option Value
- After "Re-fetch issue" Action , add a EDIT Issue Action
- Select the name of the DropDown field you want to Edit and add the smart value of the Text Field "issue.custom_text_field"
The above operations will help select the Option value in the Jira Issue View.