Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,605
Community Members
 
Community Events
165
Community Groups

Trigger listener event after workflow transition performed?

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

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

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

@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
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: AppLiger

This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity.    Atlassian:...

389 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you