How to copy or add list of Assets object to a reference Assets object attribute 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

Customers can create an Assets object and set its attributes via automation. However currently, we cannot update more than one value in a reference Assets object attribute via automation.

 

This kb covers the scenario when you need to add a list of values in a reference Assets object attribute via automation. If you are looking to append an Assets object attribute of reference type via automation refer to the kb: How to append list of objects to a reference Assets object attribute using Automation

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

Cause

We have this behavior described on the feature request   JSDCLOUD-9964 - Getting issue details... STATUS  to see the possibility of providing the functionality to be able to copy a list of objects to a reference Assets object attribute that is created via automation. 

Solution

Onboard Employees (Add more than one value in a reference Assets object attribute via automation)

You can construct an organized, and automated process to onboard new employees, to make sure new employees have access to the necessary applications when they join. 

Let's say you have a New employee request form that has an Assets object field "Application List" that stores the list of Applications the new employee needs access to. "Application List" Assets object field is fetching the objects from an object type called Applications. Also, you have an Employee object type that has an attribute "Application access" which references to object type Applications with unlimited cardinality. 

Whenever a Jira ticket reaches a specific status on the workflow you want to automatically create an Employee object and copy the list of Applications from the Assets object  field "Application List"

  1. Create an automation rule to trigger when the issue is transitioned to the desired status or an Issue created trigger
  2.  Add the following log action to see what values are stored in the Assets object field "Application List"

    {{"Application List".Key.asJsonObject("value")}}
  3. Add a Send web request action to send the Create object REST API :
       

    1. 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

    2. Add the following Web request URL:

      https://api.atlassian.com/jsm/assets/workspace/<YOUR WORKSPACE ID>/v1/object/create

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

    3. Add the following to the Custom data field:

      {
        "objectTypeId": "270",
        "attributes": [
          {
            "objectTypeAttributeId": "2352",
            "objectAttributeValues": [
              {
                "value": "{{issue.summary}}"
              }
            ]
          },
      {
            "objectTypeAttributeId": "2355",
            "objectAttributeValues": [{{"Application List".Key.asJsonObject("value")}}]
          }
        ]
      }
  4. You can also enable the "Delay execution of subsequent rule actions until we've received a response for this web request" if you also want to select this newly created object in another Assets object field. So if you have an Assets object field "Employee" that fetches Employee objects, then the below smart value returns the object key of the newly created object:

    {{webhookResponse.body.objectKey}}

    Add the following action to set the Assets object field to the newly created object:

  5. Here is how the rule execution looks like:
    Before execution:

    Execution Audit log:


    After execution:


Please reach out to support if you have any questions. 


Last modified on Sep 14, 2023

Was this helpful?

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