Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

find a way to filter attachment in automation via smartvalues

Pablo
Contributor
August 31, 2023

Hi

i've been looking for a while for a way to filter out all attachments in issue and email this filtered list to someone.

 

It basically works when I'm trying to achieve this via automation. ISmply putting this in content:

<ul>
   {{#issue.attachment}}
      <li>
         <a href="{{content}}">{{filename}} </a>
      </li>
   {{/}}
</ul>

 

 

but maybe someone knows how to filter attachments added ONLY BY user who is not REPORTER of current issue?

 

Regards

1 answer

0 votes
Mark Segall
Community Champion
August 31, 2023

Hi @Pablo 

You may need to doublecheck my syntax, but I think you could do something along the lines of this:

<ul>
   {{#issue.attachment}}
      {{#if(not(equals(attachment.author,issue.reporter)))}}
         <li>
            <a href="{{content}}">{{filename}} </a>
         </li>
      {{/}}

   {{/}}
</ul>
Pablo
Contributor
August 31, 2023

hi

thanks for this reply

unfortunatelly this is not working

 

in Your suggestion (as far as i know) this parts:

attachment.author 
issue.reporter

 are empty

i found that attachment.author should be just author - it returns atlassianId - which is  good enough so I've also tried other ways like this etc

<ul>
   {{#issue.attachment}}
      {{#if(not(equals(author,issue.reporter)))}}
         <li>
            <a href="{{content}}">{{filename}} </a>
         </li>
      {{/}}

   {{/}}
</ul>

 

 

but still i have no idea why inside this part <ul>HERE</ul> issue reporter is empty

{{issue.reporter}}  <<== works here
<ul>

   {{#issue.attachment}}
      {{#if(not(equals(author,issue.reporter)))}} <<== issue.reporter returns empty value
         <li>
            <a href="{{content}}">{{filename}} </a>
         </li>
      {{/}}

   {{/}}
</ul>

 

but outside of is - this smart value works perfectly;/

Mark Segall
Community Champion
September 1, 2023

Good catch on removing "attachment." from the smart value.  You're already inside the attachment so it only requires author and I think this is related to the other issue at play. Because you're inside the attachment, it's looking for attachment.issue.reporter which obviously doesn't exist and thus the empty string.  Maybe you can surround issue.reporter with curly braces like this:

<ul>
   {{#issue.attachment}}
      {{#if(not(equals(author,{{issue.reporter}})))}}
         <li>
            <a href="{{content}}">{{filename}} </a>
         </li>
      {{/}}
   {{/}}
</ul>
Pablo
Contributor
September 4, 2023

i've checked few other possibilities and same - failure;/

Pablo
Contributor
September 4, 2023

I've checked few other options and it seems this is a no can do via automation stuff

Mark Segall
Community Champion
September 5, 2023

Before we give up on this, let's try this approach... I think the issue is that the rule is struggling to navigate into the attachment then back up to the parent issue within the same sequence.  In my test environment, I added a variable just before the send email action to capture the reporter.  This seems to work in my limited testing:

  • ACTION: Create Variable
    • varReporter
    • {{issue.Reporter}}
  • ACTION: Send Email
    • <ul>
         {{#issue.attachment}}
            {{#if(not(equals(author,varReporter)))}}
               <li>
                  <a href="{{content}}">{{filename}} </a>
               </li>
            {{/}}
         {{/}}
      </ul>

Again, this was with limited testing, but it does seem to work.

Pablo
Contributor
September 5, 2023

I love the way of thinking in this idea

so I've left everything to check it

 

unfortunately - result was the same ;/

Mark Segall
Community Champion
September 5, 2023

The result was the same how?  You had errors or it ignored the if condition?

Pablo
Contributor
September 5, 2023

sure - clarifying :)

i've tried this code

{{varReporter}}
<ul>
{{#issue.attachment}}
{{#if(not(equals(author,varReporter)))}}
<li>
<a href="{{content}}">{{filename}} - {{varReporter}} - {{author}}</a>
</li>
{{/}}
{{/}}
</ul>

 and Mail I've received looked like this

Screenshot 2023-09-06 at 07.16.13.png

 

so

this means (as far as i uderstand that this code wors preety much like this

 {{varReporter}} - this works
<ul>
{{#issue.attachment}}
{{#if(not(equals(author,varReporter)))}} <<== here varReporter returns null
<li>
<a href="{{content}}">{{filename}} - {{varReporter}} - {{author}}</a> <<== here {{varReporter}} returns null
</li>
{{/}}
{{/}}
</ul>

sorry - i don't know how to explain this other way;/

Mark Segall
Community Champion
September 6, 2023

Thanks for the added context. It appears that we're encountering the exact same issue then with the variable as we did trying to navigate out of the attachment as the rule is likely reading varReporter as attachment.varReporter which would return nothing.  Let me think on this one a little bit more.  We may need to attack this in a different way.  There are also several other smart value ninjas in the community who may chime in.

Pablo
Contributor
September 7, 2023

thanks a lot - it's good to know that someone is also out there fighting :D

 

Regards

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events