Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to set Asset object field in Automation using additional field

Joseph Lam November 27, 2024

I am trying to use automation to set the asset object field by using JSON additional field. 

 

I saw a similar question posted: 

https://community.atlassian.com/t5/Jira-Service-Management/Can-you-set-multiple-objects-through-Jira-automation-for-an/qaq-p/2494648

 @Tom Brown:

It doesn't work when you try to use JSON and Advanced field editing. For me it worked, when I edited the custom object type field and set value as:

Someone answered it wont work if using additional field.

However, in my use case, I would have same field name for that asset object field, which means I must use JSON additional field. 

Is it a bug or technial limitation that we cannot use additional field to set the asset object field?

---

We tried two cases but both failed:

1. Using lookupObjects

Screenshot 2024-11-28 at 2.53.25 PM.png

Then, we use edit issue in the automation with:

{
"fields": {
"customfield_10425": [{{lookupObjects}}]
}
}

The audit logs shows us the json field is not valid.

Screenshot 2024-11-28 at 2.55.05 PM.png

Then we tried to transform the data to be a valid json format as:

{"key": "xxxx"}

by using {{#lookupObjects}}{"key": "{{Key}}"}{{^last}},{{/}}{{/}}

 

2. Using tranformed lookupObjects

Screenshot 2024-11-28 at 3.12.48 PM.png

Then, we use edit issue in the automation with:

{
"fields": {
"customfield_10425": [{{#lookupObjects}}{"key": "{{Key}}"}{{^last}},{{/}}{{/}}]
}
}

Screenshot 2024-11-28 at 3.13.00 PM.png

The audit log and the automation run is success; However, the field didnt have a value we have passed. 

Screenshot 2024-11-28 at 3.15.47 PM.png

 


So, is there any successful case that set an Asset Object field using the Additional Field (JSON) from Edit Issue in the Automation?

3 answers

1 accepted

1 vote
Answer accepted
Joseph Lam November 29, 2024

Finally I find out we can use id as the json key with workspace_id:object_id as json value to set the asset field. 

{"id": "<<your_workspace_id>>:{{id}}"}

I got the hints from the API call from the field editing:

Screenshot 2024-11-29 at 4.40.01 PM.png

 

For my case, it would be:

{
"fields": {
"customfield_10425": [{{#lookupObjects}}{"id": "<<your_workspace_id>>:{{id}}"}{{^last}},{{/}}{{/}}]
}
}

 

For the workspace id, you can find it from the jira document: 

https://developer.atlassian.com/cloud/assets/assets-rest-api-guide/workflow/ 

0 votes
Vijay Dadi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 27, 2024

Hello @Joseph Lam ,

I would suggest you add more details while posting your questions including screenshots.

Vijay

Joseph Lam November 27, 2024

Here it's:

We tried two cases but both failed:

1. Using lookupObjects

Screenshot 2024-11-28 at 2.53.25 PM.png

Then, we use edit issue in the automation with:

{
"fields": {
"customfield_10425": [{{lookupObjects}}]
}
}

The audit logs shows us the json field is not valid.

Screenshot 2024-11-28 at 2.55.05 PM.png

Then we tried to transform the data to be a valid json format as:

{"key": "xxxx"}

by using {{#lookupObjects}}{"key": "{{Key}}"}{{^last}},{{/}}{{/}}

 

2. Using tranformed lookupObjects

Screenshot 2024-11-28 at 3.12.48 PM.png

Then, we use edit issue in the automation with:

{
"fields": {
"customfield_10425": [{{#lookupObjects}}{"key": "{{Key}}"}{{^last}},{{/}}{{/}}]
}
}

Screenshot 2024-11-28 at 3.13.00 PM.png

The audit log and the automation run is success; However, the field didnt have a value we have passed. 

Screenshot 2024-11-28 at 3.15.47 PM.png

 


So, is there any successful case that set an Asset Object field using the Additional Field (JSON) from Edit Issue in the Automation?

Vijay Dadi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 28, 2024

try this

{
"fields": {
"customfield_10425": [{{lookupObjects.jsonEncode}}]
}
}
Joseph Lam November 29, 2024

No luck, 

lookupObjects.jsonEncode

will give us []

---

Finally I find out we can use id as the json key with workspace_id:object_id as json value to set the asset field. 

{"id": "<<your_workspace_id>>:{{id}}"}

I got the hints from the API call from the field editing:

Screenshot 2024-11-29 at 4.40.01 PM.png

 

For my case, it would be:

{
"fields": {
"customfield_10425": [{{#lookupObjects}}{"id": "<<your_workspace_id>>:{{id}}"}{{^last}},{{/}}{{/}}]
}
}

 

For the workspace id, you can find it from the jira document: 

https://developer.atlassian.com/cloud/assets/assets-rest-api-guide/workflow/ 

0 votes
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 27, 2024

Hi @Joseph Lam 

Welcome to the community.

Can you please show your automation (screenshots of the rule and steps) on what you have built so far.

What is the configuration of your custom field of type assets.

Also how doe the assets scheme and related objects to your question look like.

This will help members on the community to better understand your config and how you want to set it up.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events