Hello all,
I'm trying to create a JIRA automation that would add a comment whenever an attachment is added, the comment should have the latest attachment's filename and author name.
I've tried using {{attachment.filename.last}} but that brings the last attachment in the list of attachments, which is sorted alphabetically, so that's not very useful.
However I've had success with {{attachment.created.max}} in accessing the latest added attachment, but I can only get the created date. How can I get the filename and the display name for the author from {{attachment.created.max}}?
Hello @Pierre Ibrahim
You could use {{changelog.Attachment.toString}} to get the list of latest attachment's filenames, but I dont think displayName is accessible such way unfortunately.
If your rule trigger is "Field Change" on attachment, then you could use {{initiator.displayName}} cause thats the user who is uploading the docs.
BTW, {{attachment}} smart value gives you the full list of attachments sorted by Alphabetical order, so yes you could find the latest date as you have, but it does not help us to get the corresponding filenames or displayNames since we cannot use it for lookup.. so for your use case, that smartvalue will not help.
Hope it helps and if it works, consider accepting solution so it benefits others in the future. 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.
With the answer from @Kalyan Sattaluri you have a solution for all of the current attachments using {{toString}} from the changelog.
It is possible to get the single attachment's details added, as each attachment is added, using a rule triggered on Issue Field Updated for Attachment and quite a few variables and dynamic regular expressions to search with the match() function. If you still need that, please let me know and I will post the details.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy ,
I am working on an automation which should add a comment when an attachment is added, and the comment should preferably contain a link to that last added attachment. So I would like to see the details for the solution you suggest :-)
Best regards, Helle
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Helle Friis Pedersen -- Welcome to the Atlassian Community!
I am working on an article on searching list fields, such as attachments; until I post that...
It seems a "simpler" workaround is possible as the changelog can now return just the added attachment's identifier. And so a REST API function may be called with the Send Web Request action to get the attachment's metadata, including the name, URL, etc.
Here is the rule outline:
Here is a how-to article for calling a REST API function from an automation rule: https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
Thank you so much! The coming article on searching list fields sound really interesting!
Thank you for outlining the automation rule. I will look into this to see if I am able to create the automation I need.
By the way, do you know if it is possible to "catch" the event that an attachment is added via a workflow screen? The trigger on field value added for Attachments seems to only work for attachments added directly to the issue screen.
Best regards, Helle
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I do not know that.
You could experiment with a Jira site webhook on "attachment created" and intercept that with a webhook trigger. That should confirm if attachment added on the workflow screen sends the event. To try this, create the rule first to get the webhook URL and then use that when setting up the site webhook.
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.