Find the previous attribute values when using "Object Updated" trigger in an automation rule

Still need help?

The Atlassian Community is here for you.

Ask the community

 

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

   

Summary

When an issue is edited using automation, the {{changelog}} smart value  allows automation to access recent changes made to the issue fields. However we do not have a way to achieve the same when using an Object updated trigger, we cannot use {{changelog}} smart value to access recent changes made to object attributes. 

However we do have a REST API end point  GET object history to help us access this information. We can use the Send web request action on this endpoint and work with the response.

Solution

To find the details where a single attribute is changed using automation, follow the below steps: 

  1. Go to your automation rule that has the Object Updated  trigger.
  2. After your Object updated trigger, add a Send web request action and utilize this action to get the history of the object via  GET object history API.

    1. In the WebhookURL section add the below endpoint with your <WorkspaceID>. Use the {{object.id}} smart value to replace the objectid, so that we send the REST API for each object id in the ObjectList:

      https://api.atlassian.com/jsm/insight/workspace/<WorkspaceID>/v1/object/{{object.id}}/history

      If you are not aware of the workspace id: Find your workspace ID

    2. In the Authorization header make sure that you add the keyword Basic followed by the base64 of your emailaddress:APItoken. So if the base64 of the emailaddress:APItoken is AB12XY45 then to the Authorization header add the value Basic AB12XY45
    3. Enable the "Delay execution of subsequent rule actions until we've received a response for this web request"
  3. Then, you can add any action and access the latest changed attribute and its previous and new values using below smart-values:

    {{webhookResponse.body.first.affectedAttribute}}
    {{webhookResponse.body.first.oldValue}}
    {{webhookResponse.body.first.newValue}}

When there are multiple attributes that are updated at the same time for an object, we can use advanced branching to iterate over the results obtained from response of previous step and can only list out those values that we require using condition as per our requirement. The below example explains how we can return all the attributes that have been changed on the date when the automation rule is triggered:

  1. After the second step in the above rule(after Object updated trigger, and a Send web request action to get object history) add a new action. Click on New branch > Advanced branching and create the below smart variable to capture the webhook response:
  2. In this branch, add a condition by going to New condition > Advanced compare condition to compare the date in the webhook response with the current date as shown below:
  3. Next, you can use the below smart values to access all the attributes changed on that date, its previous and new values, date when they were changed and the user who changed them using below smart-values:

    {{var.affectedAttribute}} 
    {{var.oldValue}}
    {{var.newValue}}
    {{var.created}}
    {{var.actor}}

    For more information on how to manipulate date smart values, refer to Examples of using smart values with dates.



Last modified on Nov 5, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.