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.
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:
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:
Here is the example web request:
https://your-domain.atlassian.net/rest/service-registry-api/service?query={{#urlEncode}}{{issue.Service Info.Service.Name}}{{/}}
{{#webhookResponse.body.services.get(0)}}{{id}}{{/}}
{
"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}}"
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.
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:
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
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.
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
if {{issue.Service Info.Assignment Team Group}} does not equal empty
Assignment Team Group = {{issue.Service Info.Assignment Team Group}}
Is Security Approval Required?
if {{issue.Service Info.Security Approval}} equals true
Is Security Approval Required? = Yes
Request Participants
users = {{#issue.Service Info.Request Participants}} {{accountId}} {{^last},{{/}}{{/}
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:)
Natalya Ozhigova
Atlassian Administrator
Itransition
Belarus
3 accepted answers
0 comments