Trigger listener event after workflow transition performed?

Teja June 22, 2022

Hi Team,

We have been auto updating custom user picker based on multi select list field using custom listener, it works fine whenever field changed, but the real problem is I want to populate the user name when specific transition (open) performed.

Any event for specific transition action performed?

Thanks
T

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 24, 2022

Hi @Teja

Since you want to trigger the update once the transition is performed, why not use the Post-Function instead?

Could you please share the current code you are using so I can review it and provide some feedback?

Thank you and Kind regards,

Ram

Teja June 25, 2022

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

For example: Release Note (User Picker field) need to populate user based on our Module list and another associated field named Documentation.

Here is my piece of code:

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

//Module [Single select list field
CustomField moduleCustomField = customFieldManager.getCustomFieldObject('customfield_15300')

//Release Notes Author [single user picker field]
CustomField releaseNoteAuthorUserField = customFieldManager.getCustomFieldObject('customfield_14101')

Option moduleVal = null
def releaseAuthName = null

final Map<String, String> MODULE_RELEASE_NOTES_AUTHOR_MAP = new HashMap<>()

String releaseNotesaAutherValue = null

// Mapping for release notes Author
MODULE_RELEASE_NOTES_AUTHOR_MAP.put('Module', 'user')
MODULE_RELEASE_NOTES_AUTHOR_MAP.put('Module1', 'user1')
MODULE_RELEASE_NOTES_AUTHOR_MAP.put('Module2', 'user2')
MODULE_RELEASE_NOTES_AUTHOR_MAP.put('Module3', 'user3')


// Populate Release Notes Author update.
def releaseNoteValue = currentIssue.getCustomFieldValue(releaseNoteAuthorUserField)

//Check Release Note Author field is empty
if (releaseNoteValue == null){
moduleVal = (Option) immutableIssue.getCustomFieldValue(moduleCustomField)
String moduleName = moduleVal.getValue()

//Check for project and Issuetype
if((projectName.equals('XYZ') && issueTypeName.equals('Epic'))){
def documentationValue = issue.getCustomFieldValue(documentationType);

//Iterate documentation value in the list
if (documentationValue instanceof Collection) {
Collection<Option> coll = (Collection)documentationValue;
for (Object obj : coll) {
if (obj instanceof Option) {
Option opt = (Option) obj;
//Check if these values contains in Documentaion field
if ("User Guide".contains(opt.getValue() as String) || ("Customer Bulletin".contains(opt.getValue() as String))) {
releaseNotesaAutherValue = MODULE_RELEASE_NOTES_AUTHOR_MAP.get(moduleName)
releaseAuthName = userManager.getUserByName(releaseNotesaAutherValue)
log.info('Release Notes Author on Issue Update' + releaseAuthName)
}
}
}
}
//Update Release Note Author
releaseNoteAuthorUserField.updateValue(null, currentIssue, new ModifiedValue(currentIssue.getCustomFieldValue(releaseNoteAuthorUserField), releaseAuthName), changeHolder)
}
}

Thanks & Regards
Teja

Teja June 27, 2022

@Ram Kumar Aravindakshan _Adaptavist_ 

I think when I perform the workflow transition the Generic Event was fired, is there any chance we use particular 'Generic Event' for that transition.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events