Assets Automation - Trigger rule based on attribute update for JSM Cloud

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

Currently, you can trigger an automation rule whenever there is an update to an object schema using the "Object" trigger.

While you can "filter" the object using an AQL condition so the rule only continues to execute if the object is from a specific object type, you can't do the same for an attribute with the AQL condition. A request for this feature is being tracked below:

However, we have the GET object history REST API endpoint, so we can determine which attribute was most recently updated to work around this limitation. We can use the Send web request action with this endpoint to access this information and work with the response.

Requirements

Before setting up the Send web request action in your automation rule, get the following information:

The following page also has additional instructions on how to use the Send Web Request action if you want to learn more:

Solution

To get the attribute that was most recently updated, follow these 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 object's history via  GET object history API.

    1. In the WebhookURL section, add this URL with your <WorkspaceID>. Use the {{object.id}} smart value to replace the objectid so that we send the request for the object that triggered the rule:

      https://api.atlassian.com/jsm/assets/workspace/<WorkspaceID>/v1/object/{{object.id}}/history
    2. Use GET as the method.
    3. Leave "Web Request Body" as Empty.
    4. Enable the "Delay execution of subsequent rule actions until we've received a response for this web request"
    5. In the Authorization header, make sure that you add the keyword Basic followed by the base64 of your emailaddress:APItoken that you encoded earlier. So if the base64 of the emailaddress:APItoken is AB12XY45, then you would add the Basic AB12XY45 value to the Authorization header.

After the Send Web Request action is configured, we can access the response data to determine which attribute was most recently updated and whether the rule should continue or not. To do this, add a {{smart values}} condition with the following values:

  • First value: {{webResponse.body.first.affectedAttribute}}
  • Condition: Equals
  • Second Value: <Name of the Attribute>

I'm using "Warranty" as the attribute's name in the example above. This means that the automation rule will only execute its actions (below this condition) when the attribute that was most recently changed was the "Warranty" attribute. If another attribute is changed, then the actions won't be executed.

Full automation rule:



Note

In Scenario's where you would like to capture more details of the Attribute that was Updated you can Log the Smart Value 

{{webResponse.body}}

To compare the Old Value of the Attribute against its new value you can capture the following Smart Values:

  • Old Value
{{webResponse.body.first.oldValue}} 
  • New Value 
{{webResponse.body.first.newValue}} 




Last modified on Dec 10, 2024

Was this helpful?

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