Forums

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

JMWE - Using the issue property jmwe.last.issue.created

Jeanne Howe
Contributor
November 14, 2018

We have two post function on our workflow. The first creates a Initiative issue in the TECH project. The second creates an Epic in the REG project. As part of the post function to create the Epic, we are using the jmwe.last.issue.created property to set the Parent Link between the Epic and the Initiative. The Initiative is created as expected. when the post function attempts to create the Epic, an error is thrown stating the newly created Initiative can not be found. Am I not setting the post function correctly?

 

PostFunction.png

 

Error.png

2 answers

1 accepted

0 votes
Answer accepted
David Fischer
Community Champion
November 17, 2018

Hi,

This is actually odd. You might want to increase the delay on the second post-function to 5 second though, to give Jira time to finish creating the initiative. 

Jeanne Howe
Contributor
November 19, 2018

Hi David,

I had the delay set at 5 seconds. I tried increasing the delay to 8 seconds and 10 seconds. At these delay levels, I still see the message that it can not find the Initiative and the Parent Link is not being set.

The Initiative and the Epic (when I am trying to set the Parent Link) are being created in 2 different projects. Could this be ab issue?

 

Jeanne

Jeanne Howe
Contributor
November 19, 2018

CORRECTION:

I am still seeing the same error - can not find the Initiative

Jeanne Howe
Contributor
November 19, 2018

Looking in the log. There appears to be a space added to the custom field when it searches for the Initiative. Could this prevent JMWE from finding the Initiative?

 

Space.png

I have verified the post function. There is no space in the post function

David Fischer
Community Champion
November 19, 2018

Good catch! That is indeed the problem. Jira does trim spaces around issue keys.

And I check your JMWE logs, and in fact you do have a leading space in your template for the value of the Initiative field:

>>> {{ issue | issueProperty("jmwe.last.issue.created")}}<<<

(I wrapped the code between >>> and <<< to make the space obvious) 

Jeanne Howe
Contributor
November 20, 2018

Once again, YOU ARE MY HERO!

David Fischer
Community Champion
November 20, 2018

Happy to be of service :)

0 votes
Jeanne Howe
Contributor
August 18, 2021

Hi David,

Not sure if I should reopen this issue or create a new one. 

We are currently migrating from Jira Cloud to Jira On-prem. How would I convert this code to work on-prem?

{{issue | issueProperty("jmwe.last.issue.created")}} 

David Fischer
Community Champion
August 18, 2021

Hi @Jeanne Howe 

there is no direct equivalent on Jira Server, but for your requirement, you can use 

transientVars.newIssue

which contains the issue created by the most recent Create Issue(s) post-function in the same transition.

Jeanne Howe
Contributor
August 31, 2021

David,

How would I save this value so that I can use it to set the Parent Link in the Post Function?

Once I create the initial issue, I need to create two additional issues.

Each of these additional issues need to have the Parent Link field set to the key of the first issue I created.

  • First Post Function:
    • Create Issue ABC-123
  • Second Post Function:
    • Create HIJ-456
    • Parent Link field set to ABC-123
  • Third Post Function
    • Create XYZ-789
    • Parent Link field set to ABC-123

 

I believe I should be using transientVars.newIssue?.key but I have not been successful in setting the value so I can re-use multiple times.

 

Jeanne

David Fischer
Community Champion
August 31, 2021

Hi @Jeanne Howe ,

you can simply, in the "post-creation script", save the value in another property of transientVars:

transientVars.myParentIssue = transientVars.newIssue

and then use transientVars.myParentIssue in the subsequent create issue(s) post-functions.

An even easier solution is to use the first value of the transientVars.newIssues property in the subsequent Create issue(s) post-functions:

transientVars.newIssues[0]

since transientVars.newIssues accumulates all new issues created by any Create Issue(s) post-functions in the current transition.

Suggest an answer

Log in or Sign up to answer