How to get access properties of a workflow step?

Sathish Venkat November 15, 2011

Hi All,

I need to execute certain part of a groovy script that I am having as a post function in a workflow transition based upon some value.I thought of utilizing the workflow step properties that are available.How can I access that in my groovy script,It would be great if someone provides me a sample code snippet.

I do not want to set the properties,I just need to get the values.Also I am afraid if the properties can collapse the entire workflow bcoz it happened when I tried to set properties last time using a groovy script.Is there any risk in using that.

Any help on this is appreciated.

Thanks in advance.

Sathish

3 answers

1 accepted

1 vote
Answer accepted
Sathish Venkat November 15, 2011

int id = transientVars.get("actionId");
ImmutableWorkflowDescriptor wdes = (ImmutableWorkflowDescriptor)transientVars.get("descriptor");
ActionDescriptor actDes = wdes.getAction(id);
log.debug(actDes.getMetaAttributes());

getMetaAttributes returned the property of the specific transition.

0 votes
JamieA
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.
November 15, 2011

transientVars and args are made available in the binding, both of which are Maps.

If you log.debug them you will find the properties in one of those... iirc.

Or if not, you also have the step available so, you can get them as Wojczek says.

Sathish Venkat November 15, 2011

I tried this but was not able to see the properties......

Sathish Venkat November 15, 2011

Hi Jamie,

Thanks for the post.I did not get the peoperties directly but used transientVar to get the property using below code snippet.

int id = transientVars.get("actionId");
ImmutableWorkflowDescriptor wdes = (ImmutableWorkflowDescriptor)transientVars.get("descriptor");
ActionDescriptor actDes = wdes.getAction(id);
log.debug(actDes.getMetaAttributes());

Thanks a lot for your help.

0 votes
Wojciech Seliga
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.
November 15, 2011

com.opensymphony.workflow.loader.ActionDescriptor#getMetaAttributes is what you are looking for I guess. It returns a map, so you can call get("myattributename") on the result to retrive concrete property of your workflow transition.

You get ActionDescriptor instances usually by calling appropriate method on com.opensymphony.workflow.loader.WorkflowDescriptor

I don't have experience with Groovy scripts, but AFAIK you can just invoke them in a normal way - as anything from JIRA you call in your scripts.

Sathish Venkat November 15, 2011

Hi Wojciech,

Thanks a lot.It worked like a charm.Below is the code snippet that I used to retrieve the property.

int id = transientVars.get("actionId");
ImmutableWorkflowDescriptor wdes = (ImmutableWorkflowDescriptor)transientVars.get("descriptor");
ActionDescriptor actDes = wdes.getAction(id);
log.debug(actDes.getMetaAttributes());//this gave all the properties in a map.

Tons of thanks for your help.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events