Hi!
I used smart values to list all attachments in ticket:
{{#issue.attachment}}"id":"{{id}}","filename":"{{filename}}"{{^last}},{{/}}{{/}}
and this is working perfect.
Now I created new variable in rule to get an attachment that is added in comment (Field value changed trigger is not working for this case - ttps://jira.atlassian.com/browse/AUTO-382). I'm able to get file name.
What I want to do now is to filter attachment details based on name from my smart value by using condition (https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#equals). My smart value query looks like below:
{{#issue.attachment}}{{#if(equals(attachmentName, filename))}}"id":"{{id}}","filename":"{{filename}}"{{/}}{{^last}},{{/}}{{/}}
where attachmentName is my variable. It occur that my variable is not readable inside {{#issue.attachment}}.
Is there any way that my idea will work? Maybe you can show me other way to achieve this?
Regards,
Seba
I figure it out in little different way:
Rule trigger - Issue commented
Condition - Smart Values Condition
First value - {{triggerIssue.comment.last.body}}
Condition - contains regular expression
Regular expression - \.(txt|jpg|pdf|gif|png|csv|docx|pptx|jpeg)
Create variable to get attachment filename
{{triggerIssue.comment.last.body.substringBetween("alt=\"","\"!")}}
Advanced branching
Smart value - {{issue.attachment}}
Variable name - attachmentList
Condition - Smart Values Condition
First value - {{attachmentList.filename}}
Condition - equals
Second value - {{attachmentName}}
Create variable to store attachment ID
Now I can ask Jira about attachment details based on ID :)
Well done solving your own question!
FYI as some follow-ups...
Inside the long-format, list iterator, only data from that scope (and lower) is visible. This is why your created variable was not visible inside for the condition. (My understanding is the Atlassian team has tried to solve this automation limitation several times without success.)
Another way to solve this scenario is flattening out the list, using the inline list iterator, and add a dynamic regular expression to search with match(), finally parsing the record needed with text functions. To learn more about this approach, please see this article I wrote on the method:
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 !
Thanks for your idea! Your article is added to my bookmarks with valuable info about automations!
I read it and now I'm thinking about other case where I can use it: having two lists inside one ticket. Sticking to my attachment case:
Is it possible to iterate on both lists (loop in loop)? I mean: for 1st item in my attachment list I'm comparing it to every attachment from issue.attachment, then I'm comparing 2nd item, etc.
Regards,
Seba
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Without seeing the full scenario, my answer would be: maybe ;^)
List iteration can definitely be nested, such as with this made up example:
{{#lookupIssues}}{{#components}}{{#if(equals(name.toLowerCase(), "squirrel"))}}found {{name}}; {{/}}{{/}}{{/}}
Let's see one how well this resonates with your scenario...
What if I have two lists, where one is a list of thing ID values of interest and another is list of all things (including their ID values).
I want some attribute (e.g., name) of the things where they match the ID set in list A.
To do that, I create a dynamic regular expression using list A, flatten list B into a variable, use the regex to search, and then parse.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share the screen shot of the automation esp. where you are setting attachmentName?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.
Learn more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.