How to set the 'Affected Services' field from referenced services on an Assets object attribute via automation for 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.

   

Purpose

To be able to set the 'Affected Services' field with the referenced services on an Assets object using automation. This is useful as the Affected Service' is not visible to non-licensed users on the portal, so not possible for customers to select. In this case, the customer can select an object from an Assets object custom field where the object has their relevant services referenced in an attribute.

Example

Based on a schema with object types and attributes below:

Objects under this object type will have services referenced to them:


You would like to have an Assets object custom field that lists all objects in the object type, that is available for customers to use from the portal – and from there, automatically update the 'Affected services' field with the referenced services.

Solution

  1. On the Assets object schema and object type where you would like users to select objects from, make sure to add a 'Services' attribute that references the Services schema:
  2. Create Assets object Custom field that lists all objects from the above object type and add to JSM screen. Make sure this field is available in the portal as well.
  3. Then, create automation as below:-
    1. Pick Issue Created trigger (Or any trigger depending on when you would like the 'Affected services' field to be updated)
    2. Then, add the 'Lookup objects' action. Select the Services schema and use the following query to look up all services that have a reference to the selected object on the custom field created in Step 2.

      object HAVING inR(objectType = "<Object Type Name>" AND Key in ({{issue.customfield_XXXX}}))

      (info) Replace <Object Type Name> with your object type name and issue.customfield_XXXX with the custom field ID of the field created in Step 2.

    3. Add an Edit issue action. Under 'Additional fields', in additional fields, enter the following JSON to update the 'Affected services' field:

      {
          "fields": {
              "Affected services": [
                 {{#lookupObjects}}
                   {"id": "{{Service ID}}"}{{^last}},{{/}}
                 {{/}}
               ]
          }
      }


    4. Save and publish the automation rule.
Last modified on Dec 26, 2023

Was this helpful?

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