This article provides the code snippet to copy attachment(s) that are more /or less than a specific size from the current issue to other issue(s) using Set issue fields post-function.
\uD83D\uDCD8 InstructionsInstructions
Navigate to the intended workflow to make the necessary changes in the edit and open it in Edit mode.
Select the required transition.
Select the Post functions tab and click
Add post function
.Add the Set issue fields post-function.
Select the issues , for to which the attachments should be copied , under “Target Issue(s)”.
Select the “Attachment” field and add the below Nunjucks template:
Code Block language java {% set finalAttachments = [] %} {% for att in issue.fields.attachment %} {% if (((att | field("size"))/1000) > 150) %} {% set ignored = finalAttachments.push(att) %} {% endif %} {% endfor %} {{ finalAttachments | dump(2) }}
Replace
150
in line #3 with the desired file size (in KB). Additionally, replace the logical operator used (e.g.>
in the example above) to implement the required logic.Select the “Treat value as JSON” option (select/unselect other options as per your use case)
With this, the In the example above, any attachment(s) that are more than 150 KB (modify it) in file size are copied from the current issue to the configured target issue(s)
...
Info |
---|
If this post-function is added on the create transition, select the checkbox “Delay the execution of this post-function” under “Delayed execution” and select a delay of 3 seconds. |
References
Accessing JIRA Standard fieldsJira Fields
\uD83D\uDCCB Related articles
...
Filter by label (Content by label) | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|