Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Auto-update custom fields based on Organization properties

SUMMARY

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

SCENARIO

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

  1. Getting the Organization Ids can be done using the GET Organizations Request, using the link here: Get Organizations Endpoint 

    1. 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:

  1. Setting the Property Key can be done by referencing the link here on the Organizations API: (Set Property Key endpoint)

    1. 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:

  1. It should fetch the customer Id with GET

    /rest/servicedeskapi/organization/{organizationId}/property/{propertyKey}
  2. Then it updates the custom field with the customerId from the previous PUT requests

    1. 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):

image-20220805-004423.png
The web request URL would look like this (where customerId is used for all properties that are set on each Organization):
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.

2 comments

Italo Lobato Qualisoni August 17, 2022

 

Great article @Christian Beaulieu !

Unfortunately, the Authorization header isn't encrypted as described below issue:

I hope Atlassian implements this feature or another alternative to manage secrets in Automation rules.

Charles Trilha
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 6, 2022

Nice article, Mano Chris!

Like Christian Beaulieu likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events