hey,
Is there a way to set a custom listener to run where both field ar equals the same value ??
basically, it should work when cfvalue1==cfvalue2
Best regards
Hello @Marcin Beczynski
Are you creating custom script listener?
It can be done like this:
import com.atlassian.jira.component.ComponentAccessor
def change_cf1 = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "field1"}
def change_cf2 = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "field2"}
def customFieldManger = ComponentAccessor.getCustomFieldManager()
def cf1 = customFieldManger.getCustomFieldObjectByName("field1")
def cf2 = customFieldManger.getCustomFieldObjectByName("field2")
if ((change_cf1 || change_cf2) && (event.issue.getCustomFieldValue(cf1).equals(event.issue.getCustomFieldValue(cf2))) ) {
//put your code here
}
Must listen Issue Updated event and may be need some null checks on getCustomFIeldValue :)
Hope it helps!
Ivan,
Try this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def cf1 = customFieldManager.getCustomFieldObject('customfield_10200')
def cf2 = customFieldManager.getCustomFieldObject('customfield_10201')
def cfValue1 = issue.getCustomFieldValue(cf1)
def cfValue2 = issue.getCustomFieldValue(cf2)
if (cfValue1 == cfValue2){
//code you want to run
}
Of course, you'll want to replace the custom field ID's with the ID's of your custom fields, which you can find by going to edit your custom field, and getting the ID from the URL as in the following screenshot:
Kind regards,
Tiffany
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.