Skip to end of banner
Go to start of banner

Copy attachment(s) which are more/less than a specific size.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This article provides the code snippet to copy attachment(s) that are more/less than a specific size from the current issue to other issue(s) using Set issue fields post-function.

\uD83D\uDCD8 Instructions

  1. Navigate to the intended workflow to make the necessary changes in the edit mode.

  2. Select the required transition.

  3. Select the Post functions tab and click Add post function.

  4. Add the Set issue fields post-function.

  5. Select the issues for which the attachments should be copied under “Target Issue(s)”.

  6. Select the “Attachment” field and add the below Nunjucks template:

    {% 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).

  7. Select the “Treat value as JSON” option (select/unselect other options as per your use case)

With this, the attachment(s) that are more than 150 KB (modify it) file size 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.

References

  • No labels