Automate Attribute Updates in JSM Cloud Assets
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
Learn to update object attributes with Automation smart values and functions through examples.
Solution
Example 1: Calculate the Used and Available License count
Imagine you have a License object type with a user attribute called Assigned and three number attributes: Total, Used, and Available. When you create a License object, simply enter the total licenses available and choose the users to assign them to.
You can automatically calculate the number of licenses used and available based on how many are assigned to users:
From the Global admin page of automation, create a rule that triggers when an object is created or updated
Next, add the "Edit object" action to update the Used and Available attributes with the following smart values:
Used:
1
{{object.Assigned.size}}
Available:
1
{{#=}}{{object.Total}} - {{object.Assigned.size}}{{/}}
Example 2: Calculate the end of the Warranty date
Imagine you have a Laptop object type with the date attributes Warranty Start Date and Warranty End Date, and a number attribute Warranty that indicates the warranty period in months. These objects are created with the Warranty startDate attribute and the Warranty attribute.
Based on the Warranty date and number of months, we can calculate the Warranty end date:
From the Global admin page of automation, create a rule that triggers when an object is created or updated
Add an action: Create a variable named datevar.
1
{{object.Warranty startDate}}
Add an action: Create a variable to create months.
1
{{object.Warranty}}
Next, add the "Edit object" action to update the Warranty endDate attribute with the below smart value:
1
{{datevar.toDate.plusMonths(months.asNumber)}}
Additional tip
While we wait for bug JSDCLOUD-10177 to be fixed, If you want to calculate the difference between an object date field and today when an object is updated, then use the below steps after the object updated trigger is added:
Create variabledatevar1 to save the smartvalue {{object.Warranty startdate}}
Create variable datevar2 to save the smartvalue {{datevar1.toDate.jqlDate}}
Then use the below smart value to find the difference between Warranty startdate and today:
{{datevar2.toDate.diff(now).days}} OR
{{now.diff(datevar2.toDate).days}} OR
{{datevar2.toDate.diff(now).days.abs}}
For more information refer to Examples of using smart values with dates
Example 3: Update the object status to Expired after the License Expiry
Refer to the article How to update object status to expired using automation in Assets
Example 4: Auto-populate approvers from Asset objects
Refer to the article How to auto-populate approvers from Asset objects attributes using automation in Assets
Example 5: Append a list of objects to a reference Asset object attribute using Automation
Refer to the article How to append list of objects to a reference Assets object attribute using Automation
Was this helpful?