Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JMWE - How to use transientVars.newIssues[0]

Jeanne Howe
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 14, 2021

I have 2 post functions set on my workflow. Each post function creates a new issue.

When the second issue is created, I would like to set the Parent Link field within the second issue to the key of the first issue that was created.

This can be accomplished using the transientVars.newIssues[0] property. Can anyone provide examples of how this should be formatted within the post function. I am receiving an error stating the  transientVars.newIssues[0] can not be found.

I have tested the workflow without setting this value and the issues are created as expected. This leads me to believe it is my formatting of the post function, i.e. pilot error.

Below you can see the field, Parent Link, being set. It is the Groovy Template I need help to format.

transvar.png

1 answer

1 accepted

2 votes
Answer accepted
David Fischer
Community Champion
September 14, 2021

Hi @Jeanne Howe ,

two things:

  1. you need to select "Set field value to Groovy Expression", not "Set field value to constant or Groovy Template"
  2. You cannot use "Test Groovy Script" in that case, since the transientVars variable won't contain anything until you actually run the transition
Jeanne Howe
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 14, 2021

Hi David,

When set to a Groovy Expression the following error occurs:

Error occurred while creating issue. This could be due to a plugin being incompatible with this version of JIRA. For more details please consult the logs, and see: http://confluence.atlassian.com/x/3McB com.atlassian.jira.issue.IssueImpl cannot be cast to com.atlassian.rm.jpo.env.issues.SimpleIssueAttributes

It seems that you have tried to perform an illegal workflow operation.

If you think you shouldn't get this message, please contact your Jira administrators.

 

All my plugins are up to date. I am using
Jira 8.17.1

JMWE 6.6.1

David Fischer
Community Champion
September 14, 2021

That's odd. That means that field doesn't expect an issue object. 

What does the Expected Value help tab show for that field?

Jeanne Howe
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 14, 2021

This is what I see:

IssueFields.png

ExpectedValues.png

David Fischer
Community Champion
September 14, 2021

Right. So the field expects an issue key, so you need to use

transientVars.newIssues[0].key
Jeanne Howe
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 14, 2021

Oh man, seems so simple once you see it.

THANK YOU DAVID!

Suggest an answer

Log in or Sign up to answer