How to get the name of the postfunction programmatically in a script

Jayashree Shetty
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.
September 28, 2014

I have some set of logic to be performed in a groovy script. This requires the postfunction name that is being currently used in the transition. Based on the postfunction name i need to perform some operations. How can we get the postfunction name and details programmatically? If i have 3 subtasks and subtask workflow has this particular postfunction by name "x'. I need to check if for all of the subtasks this postfunctions is initiated  not

2 answers

1 accepted

1 vote
Answer accepted
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.
September 28, 2014

This sounds like you're asking the same as: https://answers.atlassian.com/questions/9372093

Jayashree Shetty
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.
September 28, 2014

Its part of that question. I know by your answer to the question above that all postfunctions do get fired. But is it possible to get the name of the postfunction from the current issue which is in action?

Jayashree Shetty
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.
September 28, 2014

Like we have getallworkflowactions by passing issue id.On the similar grounds do we have something similar to this for postfunction too. I havent come across so just wanted to know if there's something like this.

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.
September 28, 2014

I can't think of any use for getting the name of the current post-function in the code. You already know the name because you're in the code already.

Norman Abramovitz
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.
September 29, 2014

I am assuming there is a common function that somehow changes it logic flow based upon the postfunction. Maybe pass in an argument to the common function or refactor into separate functions for each postfunction.

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.
September 29, 2014

I think there's a point being missed here - a post-function is not there to control any flow. It's too late for flow control, a post-function is there to do things because you've committed to a path. As a I said already, the name of the current post-function is utterly useless inside the post-function because it will only ever have one value.

Jayashree Shetty
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 6, 2014

Thanks Nic

Jayashree Shetty
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 6, 2014

Thanks Norman

0 votes
Norman Abramovitz
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.
September 28, 2014

This sounds like a generic groovy language issue if I understand what you are requesting.

import org.codehaus.groovy.runtime.StackTraceUtils
def getCurrentMethodName(){   def marker = new Throwable()   return StackTraceUtils.sanitize(marker).stackTrace[1].methodName }

Suggest an answer

Log in or Sign up to answer