Forums

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

Creating a ScriptRunner condition checking a custom field containing assets

Lily Driscoll October 25, 2024

I am trying to create a ScriptRunner condition within a workflow to determine if an issue's custom field contains X assets. I know multi select asset custom fields hold as an array. In script runner they are in a List, but I can figure out how to reference the objects as they are showing as below:

 

Screenshot 2024-10-25 093347.png

 

 

 

This is how is shows in the ticket and in XML:

Screenshot 2024-10-25 093439.pngScreenshot 2024-10-25 093502.png

I this code but it results in false:

 

 

issue.customfield_14962 .map(asset => asset.key) .includes("b2166d00-0d11-45d4-8aa2-6d3d154a18ab:367782")

1 answer

1 accepted

2 votes
Answer accepted
Lily Driscoll October 25, 2024

I eventually found my answer, available fields are

{"id":"b2166d00-0d11-45d4-8aa2-6d3d154a18ab:367782","objectId":"367782","workspaceId":"b2166d00-0d11-45d4-8aa2-6d3d154a18ab"},{"id":"b2166d00-0d11-45d4-8aa2-6d3d154a18ab:367790","objectId":"367790","workspaceId":"b2166d00-0d11-45d4-8aa2-6d3d154a18ab"}

 

So to validate the code was

issue.customfield_14962.some(asset =>
    asset.id == "b2166d00-0d11-45d4-8aa2-6d3d154a18ab:367782"
)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events