The purpose of this article is to illustrate how to auto-fill custom field values using a Web Request Automation Rule, after you set Organization properties on the Organization field.
Benefits and examples:
Gathering all Organizations via GET Request on the Organizations field (using Get Organizations endpoint)
Using a PUT Request while passing a payload value to set a property key value to an Organization field (using Set Property Key endpoint)
Provide a practical example of how to pass payload data into a custom field from an Automation Web Request Action
In this scenario you will be hard-coding a CustomerId (pre-determined Ids provided from a CRM, for example) for each Organization Id, so that it will then allow you to fetch that CustomerId when running a Web Request on the Automation Rule to then insert into the CustomerId custom field. This will ultimately allow you to auto-fill the customerId field value, based on which Organization is filled in on the Jira Service Management ticket (as we have hard-coded the CustomerId’s onto each Organization).
First you will need a list of the Organizations as well as the Customer Ids on the CRM that are tied to each Organization
Getting the Organization Ids can be done using the GET Organizations Request, using the link here: Get Organizations Endpoint
For the GET request (to get all Organization Id’s), it should look like the following:
curl --request GET \
--url 'https://yoursitename.atlassian.net/rest/servicedeskapi/organization' \
--header 'Authorization: Basic yourbase64encodedemailandapitoken' \
--header 'Accept: application/json'
Then you will need to run a PUT Request for each Org to create the link between the Organization and the CustomerId:
Setting the Property Key can be done by referencing the link here on the Organizations API: (Set Property Key endpoint)
For the PUT request, it should look like the following (this will assign the customerId to each Organization):
curl --request PUT \
--url 'https://yoursitename.atlassian.net/rest/servicedeskapi/organization/organizationid/property/customerId' \
--header 'Authorization: Basic yourbase64encodedemailandapitoken' \
--header 'content-type: application/json'\
--data '{
"value" : customerIdvalue
}'
After that you will need to create an Automation Rule:
It should fetch the customer Id with GET
/rest/servicedeskapi/organization/{organizationId}/property/{propertyKey}
Then it updates the custom field with the customerId from the previous PUT requests
The Automation Rule to GET the customerId (from the Organization fields properties) and then assign that customerId value to the custom customerId field:
Screenshot of exact configuration setup in my example/test instance (but using your own base64 encoded string (see link here for Base64 encoder) of your email and API token):
https://yoursitename.atlassian.net/rest/servicedeskapi/organization/{{issue.Organizations.id.urlEncode}}/property/customerId
And the smart value for the Edit Issue Action would be {{webhookResponses.body.value.value
}}
So, it will look within the JSON Payload twice to drill down to the specific Property Key (customerId you set in the previous PUT Request, because the body of the WebHook response would just be {key=customerId, value={value=222}} (instead of just 222) without using the two value attributes in the Automation Rule smart value. |
This should then allow you to create the customerId automatically when an Organization is assigned to a ticket on Issue Creation.
I hope this helps!
-Christian B.
Christian Beaulieu
JSM Support Engineer 3
Atlassian
Phoenix, Arizona
2 accepted answers
2 comments