How to update object status to expired using automation in Assets

Still need help?

The Atlassian Community is here for you.

Ask the community

 

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

   

Summary

Refer to the below example to check for expired licenses periodically and set their status to Expired. Currently, we cannot execute scheduled automation rules on objects directly based on an AQL. Here are the features to provide this functionality in the future: JSDCLOUD-10024 and JSDCLOUD-9976 Meanwhile, as a workaround, we can utilize the lookupobjects action with Advanced branching and Scheduled trigger to achieve this.

For more examples refer to the article: How to update object attribute values using automation in JSM Assets

Environment

Automation for Jira and JSM Assets

Solution

Let's assume we have an objecttype License with an attribute Status that displays if the license is active or Expired and the Expiry date attribute. We can update the license status to Expired once the license expiry is overdue.


  1. From the Global admin page of automation, create a rule with the scheduled trigger. 
  2. Add a look lookupobjects action to find the objects with an overdue expiry date that are already not marked as Expired
    (warning) Please note that the lookupobjects action can fetch at the most 100 objects at a time. So you need to schedule the automation rule in the previous step based on the maximum number of objects that might expire in a day. 

    objecttype = License AND "Expiry date" < now() AND "Status" != Expired 
  3. Add an If block with an Advanced compare condition that the lookupobject size must be greater than 0

    {{lookupObjects.size}}


  4. Add Advanced branching within the If block to start branching over each object key in the lookupobject list. Create a variable ObjectList that stores the smart value of lookupobjects:
  5. Within the branch add the Send web request action. Utilize this action to edit the object attribute via JSM Assets REST API
    In the WebhookURL section add the below endpoint with your <WorkspaceID>. Use the {{ObjectList.key}} 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/assets/workspace/<WorkspaceID>/v1/object/{{ObjectList.key}}

    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

    In this example, we are updating the object type attribute 41 which is of type status to value 8, the value for Expired status. 



Last modified on Jan 8, 2024

Was this helpful?

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