Our new Appfire Documentation Space is now live!
Take a look here! If you have any questions please email support@appfire.com
Copy attachment(s) with a specific word in the file name
This article provides the code snippet to copy attachment(s) that have a specific word in the file name from the current issue to other issue(s) using Set issue fields post-function
Instructions
Navigate to the intended workflow to make the necessary changes in the 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 which the attachments should be copied, under “Target Issue(s)”.
Select the “Attachment” field and add the below Nunjucks template:
{% set finalAttachments = [] %} {% for att in issue.fields.attachment %} {% if (att | field("filename")).includes("test") %} {% set ignored = finalAttachments.push(att) %} {% endif %} {% endfor %} {{ finalAttachments | dump(2) }}
Replace the word
test
in line #3 with the desired word.Select the “Treat value as JSON” option (select/unselect other options as per your use case)
With this, the attachment(s) that contain the word test
(modify it) in the filename are copied from the current issue to the configured target issue(s)
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.