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

JMWE Create issue(s) Post-function

Lanre January 5, 2024

I am trying to create an issue from a transition.

This is trying to replicate the branch statements in the original Jira automation. 

I want some fields to be edited when the final linked issue has been created using the post-creation script 

{% if issue | parentIssue | field("fields['Transfer']").value == "Biannual" %}
{% set issue.fields["Start Date"] = date('add',6,"Months") %}
{% elif issue | parentIssue | field("fields['Transfer']").value.value == "Annual" %}
{% set issue.fields.customfield_10089 = date('add',1,"Years") %}
{% else %}
{% set issue.fields.customfield_10089 = date('add',2,"Years") %}
{% endif %}

The script is supposed to edit the start date on the newly created linked issue and set it to the current date + 6 months, 1 year or 2 years based on the value of a field (Transfer) in the parent ticket.

I am not able to get this to work. 

Any help will be appreciated.

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 7, 2024

Hi @Lanre 

you cannot (at least not easily) modify issue fields in a post-creation script. Setting a variable the way you tried will not update the issue itself, only its in-memory view.

Why don't you put the value calculation code directly in the various fields for the newly created issue (in the "Set fields of new issue" section)? 

Also, note that in the context of the Create Issue(s) post function, the "issue" variable represents the current issue, not the issue being created. In the value scripts, the new issue isn't accessible (since it isn't created yet) but "issue" represents the current issue which in your case seems to be the parent issue of the subtask being created. And in the post-creation script, you can use the "newIssueKey" and/or "newIssueKeys" variables to access the key(s) of the newly created issue(s).

Lanre January 8, 2024

Hello David, 

Thanks for the response. I tried putting it in the part "set fields of new issue," but I got the error...

Expected a valid date or date+time but got: date('add',1,"Years")

Lanre January 8, 2024

I have achieved this by ensuring that the calculation is made on a date value.

Thanks. This is resolved. 

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 9, 2024

Hi @Lanre 

I'm glad this is now working. Can you please "Accept" the answer so that others can benefit from it?

Thanks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events