Update Insight object attribute values using automation

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 examples to understand how you can update the Insight object attributes using Automation smart values and functions.

For more examples refer to the article Update Insight object status to expired using automation

Environment

Automation for Jira and Insight asset management 

Solution


Example1: Calculate the Used and Available License count
Let's assume we have a License object type that has a user type attribute Assigned and 3 integer attributes Total, Used, and Available. Now when an admin creates a License type object they will mention the total number of licenses available and select the users to whom the license is assigned. 
 


Based on the number of licenses assigned to users, we can calculate the available and used license count automatically:

  1. From the Global admin page of automation, create a rule that triggers when an object is Created or Updated 
  2. Next, add the "Edit object" action to update the Used and Available attributes with the below smart values:
    Used

    {{object.Assigned.size}}

    Available

    {{#=}}{{object.Total}} - {{object.Assigned.size}}{{/}}




Example2: Calculate the end of Warranty date  
Let's assume there is an objecttype Laptop with date attributes Warranty startDate, Warranty endDate, and integer attribute Warranty that contains the number of months for which the warranty is provided. 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:

  1. From the Global admin page of automation, create a rule that triggers when an object is Created or Updated 
  2. Add an action Create variable to create variable datevar
    Due to the bug JSDCLOUD-10177 we cannot use the automation functions on the Insight attributes at this time, so we will use a variable to copy the date attribute, we can then apply the automation functions on it:

    {{object.Warranty startDate}}
  3. Add an action Create variable to create variable months
    Due to the missing feature AUT-1473 we cannot use a smart value inside the date.plusMonths() function

    {{object.Warranty}}
  4. Next, add the "Edit object" action to update the Warranty endDate attribute with the below smart value:

    {{datevar.toDate.plusMonths(months.asNumber)}}

tip/resting Created with Sketch.

Additional tip

While we wait for bug JSDCLOUD-10177 to be fixed, If you want to calculate the difference between an Insight date field and today when an object is updated, then use the below steps after the object updated trigger is added:

  • Create variable datevar1 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


Example3: Update the object status to Expired after the License Expiry
Refer to the article Update Insight object status to expired using automation

Example4: Auto-populate approvers from Insight objects
Refer to the article Auto-populate approvers from Insight objects


Last modified on Jan 12, 2022

Was this helpful?

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