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.
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).
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")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Lanre
I'm glad this is now working. Can you please "Accept" the answer so that others can benefit from it?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.