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

Exception on Post Function Workflow

Alvin
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 22, 2018

Hi All, I am trying to make a post function that will fire when the condition is true. can you help me? I need to fire the event when request name is ABC, if not , post function will not fire. Here is my code

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

def cField = customFieldManager.getCustomFieldObject("customfield_xxxxx")
ApplicationUser user = issue.getCustomFieldValue(cField) as ApplicationUser
UserManager userManager = ComponentAccessor.getUserManager();
issue.setReporter((user))

Thanks

3 answers

1 vote
IT User Support October 23, 2018

Hi @Nic Brough -Adaptavist- , these 3 request types shares 1 issue type. and it is service request.

Nic Brough -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.
October 23, 2018

So change it so there are two issue types.

IT User Support October 23, 2018

Hi @Nic Brough -Adaptavist-, I think I can achieved it using fire post function when a condition is true

0 votes
IT User Support October 22, 2018

Hi @Nic Brough -Adaptavist- , Scenario is I have several request. example is I have 3 request . ABC, DEF, GHI . when the user raise a request using ABC, my post function will fire. if not., post function wont fire. 

Nic Brough -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.
October 22, 2018

Ok, so have two workflows, one with the post-function, and one without it.  Set up Jira to use the workflow with the function for project ABC, and use the other for projects DEF and GHI

IT User Support October 22, 2018

Hi @Nic Brough -Adaptavist- , can't I just use the fire an event when the condition is true? I want to utilize that if condition, can you help me?

Nic Brough -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.
October 22, 2018

Firing an event has nothing to do with what you're trying to do.

Conditions control the use of transitions, they would block the whole transition (so not only would you not run your post-function, you would also not make any changes to the issue, or fire the events)

IT User Support October 22, 2018

Hi @Nic Brough -Adaptavist- , can you then enlighten me where to use these firing an event when condition is true? 

Nic Brough -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.
October 22, 2018

You don't.  Conditions are there to control the use of transitions.  Events have nothing to do with what you have described as what  you want.

Your requirement appears to be to have one set of issues run this post function, and another set not.  To do that, separate out the issues into two different types, and have different workflows for them.

Alvin
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 22, 2018

@Hi @Nic Brough -Adaptavist- , what about if the post function will fire only if a custom field has a value? can I do that on post function

Alvin
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 22, 2018

Hi @Nic Brough -Adaptavist- , I am not talking about projects, I am talking about request. 

Nic Brough -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.
October 23, 2018

Ok, I assumed they were projects.  But, lets say ABC, DEF and GHI are request types.

You can map ABC to issue-type 1, and then DEF and GHI to issue-type 2, then you use the workflow with the post-function for issue-type 1 and the other one without the function for issue-type 2.

0 votes
Nic Brough -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.
October 22, 2018

A post function always "fires" when you go through a transition, so I'm not sure what the problem here is.

If you mean "it runs, but does nothing", then I suspect it's the setReporter call, but you will need to read the logs to see why it is failing.

IT User Support October 22, 2018

Hi @Nic Brough -Adaptavist- , what I mean is that I have several request., If user clicks on ABC request , that code post function woildn't fire. I need help on setting if condition

Nic Brough -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.
October 22, 2018

Post functions run during transitions.  Just clicking on something isn't going to run a post-function unless it is a transition you are clicking on.

I think you need to describe what you are trying to achieve first.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events