How to sync value in "Assets Custom Field", when an object changes in issue ?

Alex
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.
October 10, 2023

Hi, atlassian community!

I have a code that pulls out the value of an attribute from an object (indicated in the "Softwate" field) with which it is associated (the attribute is indicated in the "line product" field)

My main task now is to synchronize these values ​​in the .

(Make it so that when the field (object) "software" is changed the attribute in cF "line product" also changed (the one associated with this object was substituted)

 

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.component.ComponentAccessor;


def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_18429");// here replace the ID with ID of your custom field.
def issueKey = "RDY-12917";
def issueManager = ComponentAccessor.getIssueManager()
def issueObject = issueManager.getIssueObject("${issueKey}")
def cfName = "ПО (актив)"
def cfPOactiv = issueObject.getCustomFieldValue("${cfName}").findAll().join("")

 
def regStringPOactive = (cfPOactiv =~ /RFA-\d\w+/).findAll().join("") // Ключ объекта: RFA-195553 , для ПО (актив)

def attrObjLineOfProduct = Assets.getByKey("${regStringPOactive}").getAttributeValues('Линейка продукта')
def regStringLineOfProduct = (attrObjLineOfProduct =~ /\d\w+/).findAll().join("")

def keyAttrLineOfProduct = 'RFA-'+ regStringLineOfProduct
def attrNameLineOfProduct = Assets.getByKey("${keyAttrLineOfProduct}")
def regAttrValueLineOfProduct = (attrNameLineOfProduct =~ /.*\s/).findAll().join("")

 

 

Screenshot_20231010_193230.pngac.pngac2.png

 

Any help is important! Thank you. 

0 answers

Suggest an answer

Log in or Sign up to answer