How to automatically populate service-related information stored in Assets

Hello community! Have you tried to import Services and service-related information, using my algorithms? Hope, you did it and now ready to test one more automation with Assets (Insight before 2022).

This time I want to share the way we’ve automated the process of populating Service Owner (User picker (single user)), Project (Project picker (single project)), Assignee, Request Participants, and other fields that are based on the Assets object. The automation with Assets helps us to optimise resources and save time of our agents who previously filled in the fields in the issue manually.

Affected Services and Service Info fields synchronisation

First, we’ve synchronised two fields: Affected Services, a default JSM field that stores service-related information, and Service Info, a custom field that is based on the Assets Object where all additional service-related information is also stored. 

As the Affected Services field can only be seen by the users with a Jira license, we can’t add Affected Services fields to the portal forms. Thus, as a workaround, we’ve created the Service Info custom field of Assets type, added it in the request types so it is shown on the portal, and populating the information in the Affected Services field based on Service Info field and vice versa using Jira automations.

To synchronise both Affected Services and Service Info fields,we’ve used the following example automation rule: 

Screenshot from 2022-11-28 10-19-56.png

Find the related Service in Assets Object and edit Affected Services

First of all, we check if Service Info has a value but Affected Services field is empty. Jira has a separate condition related to Affected Services field, it’s named Affected Services Condition. The Service name is a mandatory attribute of the Service, so if “Service Name” is empty it means that we don’t have any Service in the Affected Services field, that is, Affected Services is empty. 

Then we do the following:

  1. Use Action: send web request and send a query with the Service name to find Service id for editing Affected Services.

Here is the example web request:

https://your-domain.atlassian.net/rest/service-registry-api/service?query={{#urlEncode}}{{issue.Service Info.Service.Name}}{{/}}
  1. Create a variable, an id of Service - “id”:
{{#webhookResponse.body.services.get(0)}}{{id}}{{/}}
  1. Edit the Affected Services field with advanced option:
{
"fields": {
     "Affected Services" : [{
         "id": "{{id}}"
     }]
}
}

To edit Service Info field when the Affected Service field is set, use the standard edit option of automation with the following parameters:

Action: Edit field

Choose: Service Info

Set value: Name LIKE "{{issue.Affected Services.get(0).Name}}"

Fields synchronisation after editing one of them

We’ve used similar rules for synchronisation of these fields when one of them is edited. But in this case, we’ve needed another trigger: field value changed for edit operation

We’ve also unchecked the Allow rule trigger checkbox to avoid the automation loop

 

Populating fields info based on Assets

On the top of the above, we can also populate our issues with the information from Assets, when the issue is created, for example. Please check the example automation rule we’ve used: 

Screenshot from 2022-11-25 16-35-48.png

 

Trigger: issue created

The rule automated the process of filling in the following fields when the issue is created.ll the fields are based on Asset object attributes, to support our internal processes: 

 

Field

Field Type

Object Attribute

Type of the Object Attribute

Service Owner

User Picker (single user)

Service Owner

User (allow single user)

Assignee

User Picker (single user)

Service Owner

User (allow single user)

Project

Project Picker (single project)

Project Key

Text

Assignment Team Group

Group Picker (single group)

Assignment Team Group

Group (allow single group))

Is Security Approval required?

Select List (single choice)

Security Approval

Boolean

Request Participants

Request Participants

Request Participants

User (allow multiple users)

 

Let’s puzzle out the automation together. 

 

Service Owner

  1. Add the following condition for checking if the related Assets object contains the value for the attribute. We use our custom field based on Service Info object:

If {{issue.Service Info.Service Owner}} is not empty

If you are not adding this condition and the value is empty, the rule will throw an error.

  1. Set Action: edit issue and add:

Service Owner= {{issue.Service Info.Service Owner}}

The same way we can set Assignee to {{issue.Service Info.Service Owner}}

 

Project

The information in Assets is stored as text. In our case, the custom field Project has Project picker (single project) type. So, we’ve edited this field with the advanced section, previously creating a variable with the following value:

JiraProject = {{issue.Service Info.Project Key}} 

Json in the advanced section:

{
    "fields": {
        "Project": {{JiraProject.asJsonObject("key")}}
    }
}

 

Assignment Team Group

  1. Set the following condition:

if {{issue.Service Info.Assignment Team Group}} does not equal empty

  1. Choose Action: edit issue and add:

Assignment Team Group = {{issue.Service Info.Assignment Team Group}}

 

Is Security Approval Required?

  1. As Security Approval is a boolean attribute, set the following condition:

if {{issue.Service Info.Security Approval}} equals true

  1. Choose Action: edit issue and set the value:

Is Security Approval Required? = Yes

 

Request Participants

  1. Create variable users by adding:

users = {{#issue.Service Info.Request Participants}} {{accountId}} {{^last},{{/}}{{/}

  1. Choose Action: edit issue and set the value:

Request participants = {{users}}

 

Hope, my algorithm has been helpful and you’ve succeeded in automation with Assets. Please, share your wins and leave questions in comments:)

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events