Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How add condition in Listener ?

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.
Oct 12, 2023

Hi, everyone!

I have code in a listener and I want to add a condition so that this listener will only fire if the myCF field has been changed.

And make it work for the Сurrent task and not just for: def issueKey = "RDY-12917" :

 

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

def customFieldPOactive = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_18429")
def issueManager = ComponentAccessor.getIssueManager()
def issueObject = issueManager.getIssueObject("${issueKey}")
def cfName = "Software(active)"
def cfPOactiv = issueObject.getCustomFieldValue("${cfName}").findAll().join("")

def regStringPOactive = (cfPOactiv =~ /RFA-\d\w+/).findAll().join("") // key for object "Software(active)": RFA-195553
def attrObjLineOfProduct = Assets.getByKey("${regStringPOactive}").getAttributeValues('Line of Product')
def regStringLineOfProduct = (attrObjLineOfProduct =~ /\d\w+/).findAll().join("")
def keyAttrLineOfProduct = 'RFA-'+ regStringLineOfProduct
def attrNameLineOfProduct = Assets.getByKey("${keyAttrLineOfProduct}")
def AttrValueLineOfProduct = (attrNameLineOfProduct =~ /\s*\(RFA-\d+\)/).findAll().join("") // value in attribute 'Line of Product' (in object - "Software(active)")

//<---------------------------------- Add value name in CF "Line of Product" --------------------------------------------------------------------------->

issueObject.update {
setCustomFieldValue('Line of Product') {
set(AttrValueLineOfProduct)

}

}

//<---------------------------------- Add value name in CF "Vendor(active)" ----------------------------------------------------------------------------->

def attrObjVendor = Assets.getByKey("${regStringPOactive}").getAttributeValues('Developer')
def regStringVendor = (attrObjVendor =~ /\d\w+/).findAll().join("")
def keyAttrVendor = 'RFA-'+ regStringVendor
def attrNameVendor = Assets.getByKey("${keyAttrVendor}")
def AttrValueVendor = (attrNameVendor =~ /\s*\(RFA-\d+\)/).findAll().join("") // // value in attribute 'Vendor(active)' (in object - "Software(active)")

issueObject.update {
setCustomFieldValue('Vendor(active)') {
set(AttrValueVendor)

}

}

Any help is important!

Thank you

1 answer

1 accepted

1 vote
Answer accepted

Hi @Alex

you can use the following:

 

Issue issue = event.issue
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field=="YOURCUSTOMFIELD"}
if (change){
}
Let me know if you cannot manage it.
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.
Oct 13, 2023

@Miklos Tix 
Hello! Thank you very much for your work! It worked great! :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events