Our new Appfire Documentation Space is now live!
Take a look here! If you have any questions please email support@appfire.com
Delete attachment(s) with a specific word in the file name
This article provides the code snippet to delete attachment(s) that have a specific word in the file name using Build-your-own (scripted) 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 below Nunjucks script:
{% for att in issue.fields.attachment %} {% if (att | field("filename")).includes("test") %} {{ "/rest/api/2/attachment/:id" | callJira(verb="DELETE",params={"id":att | field("id")}) }} {% endif %} {% endfor %}
The above template deletes the attachment(s) that contain the word test
in the filename (modify test
in line #2 with your desired text)
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.