Referencing the original issue when inside #issue."customfield" not working.

Robert Valentine June 21, 2022

I'm having trouble referencing the triggering issue when creating a web request for Status Page using smart fields as part of Jira Cloud Automation.

 

The code  I'm using is below.

{{#issue."Affected Status Page Components"}} "{{value.split("#").get(1)}}": "{{issue."Status Page Component Status"}}"{{^last}}, {{/}}{{/}}

 

The broken portion is the "{{issue."Status Page Component Status"}}"

It results in a value of ""

Inputting a static string works but is undesirable

 

I've tried some of the following.

  • triggerIssue."Status Page Component Status"
  • parent.Issue."Status Page Component Status"
  • parent."Status Page Component Status"

1 answer

1 accepted

0 votes
Answer accepted
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 22, 2022

Hi @Robert Valentine ,

for deeper understanding of your problem:

Could you please describe in more details/from a use case perspective what the automation rule is trying to solve? Furthetmore a screenshot of the current automation rule would be helpful to get an overview.

Is „Status Page Component Status“ a custom field in your issue? Have you tried to select the customfiel without ““? I only know the notation {{issue.customFiel}} (eg. {{issue.description}} ).

 

Best
Stefan

Robert Valentine June 22, 2022

"{{issue."Status Page Component Status"}}"

This is referencing a custom field, yes.

This works fine in a comment.

This works fine in the webhook custom payload normally.

 

However, in the context of, {{#issue."Affected Status Page Components"}} "{{value.split("#").get(1)}}": "{{issue."Status Page Component Status"}}"{{^last}}, {{/}}{{/}}
It does not work.

 

The expected result is:

"component name": "component status", "component name": "component status"

 

The actual result is:

"component name": "", "component name": ""

 

As a breakdown of the line's inputs/outputs....

 {{#issue."Affected Status Page Components"}}

This is a multiple select list. The contents look similar to this.

component name #shjkdfhjk287376

component name #82h891h43987

 

We printing all of the selected contents of this field using this line

See: https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-lists/

 

The following is basically composing a string with a bit of a foreach as per the documentation.

"{{value.split("#").get(1)}}":

Here we split the value, and get the first result, this is the component ID of the component in Status Page.  It then wraps it in quotes and ends it with a colon.

See: https://community.atlassian.com/t5/Marketplace-Apps-Integrations/JIRA-Automation-How-to-use-Smart-Fields-split-function/qaq-p/700234

 

Still in the loop

This is the broken part, the rest works 100% fine.

"{{issue."Status Page Component Status"}}"

This should reference the value of the issue's custom field Status Page Component Status

This is a single value select list. It is used to determine the severity of the impact on all the selected components. It is then wrapped in quotes.

Basic referencing as per: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/

 

{{^last}}, {{/}}{{/}}

This means except for the last value, set a , after everything else before it.

I believe the {{/}} is some kind of logic ending symbol, but I just copied it from the instructions in the documentation see using lists.

 

The net result is a subset of a web request that lists the components, and gives them a severity of impact. In this case, they will all be set to the same severity. This is put into the rest of a web request that updates a status page with an incident that actually updates component statuses.

 

To reiterate, all other code works but that section, which appears to be broken as I am referencing the issue during, what I can only imagine is another context of code.

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 2022

Hi @Robert Valentine 

I couldn´t solve this with smart value only. I guess the point is that within the iteration only the field that is iterated is in context to deliver data.

AND:
assuming I got your requirement right you´d like to iterate over the multi-select field and for each value in there write that value and add the value of the other single select field. Please correct me if I´m wrong.

If this is the case I tried solve this with a for each branch (see screenshot):

image.pngimage.png

I hope this is helpful to solve your problem.

Looking forward to your feedback.

 

Best
Stefan

Robert Valentine July 6, 2022

This might work in a multistage setup if I can concatenate all the results back down.

The end use case is to shove this information into a custom payload for a webrequest.

So presumably, anytime one of the values changed for either dropdown I would have to recalculate the values and put them into another custom field or temporary storage location.

I just don't know how to threadsafe the advanced branching.

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 2022

sorry but can‘t follow your idea...

your rule will always only be calculated when triggered.

So I‘m sure you could concatenate the result with split and concatenate.

Best
Stefan

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 2022

Please also provide a screenshot of your whole automation rule? This eould be very helpful (for me as well as for other answerers) to understand the whole context.

Best
Stefan

Robert Valentine July 6, 2022

Below is what the web request looks like in the intended flow.

web_request.JPG

 

It is triggered like so...

incident_flow.JPG

 

In order to use branching, I would have to branch, save the results of each of the branches somewhere, then concatenate them back together when creating the web request.

Robert Valentine July 6, 2022

The thread safety of branching is in question.

Because if I made a branch that...

  1. calculated the string I wanted for one multiselect option
  2. grabbed a custom field text box's value
  3. added the string to said value
  4. assigned it back to the custom field

Then if it's not thread safe, the string may get grabbed between steps 2 and 3 by another thread.

This would result in incorrect results in said custom field before all branches resolve.

James Navin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2022

Hi there,

@Stefan Salzl is correct that at the moment the context within the iteration doesn't have access to the originating issue (e.g. it is restricted to the loop context). I have raised an issue to look at adding it - https://jira.atlassian.com/browse/JSWCLOUD-23239

In the meantime, you could try to reform the iteration as a mapping over the collection. Something like:

{{issue."Affected Status Page Components".value.split("#").get(1).concat(":").concat(issue."Status Page Component Status")}}

Hope that helps.

Cheers,

James

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2022

Hi @James Navin 

thanks for the great input and the approval of my assumption :) I was also thinking of the .concat method but wasn´t able to do. Thanks for the hint. Always great to learn things here :)

Best
Stefan

Robert Valentine July 11, 2022

Wish I could highlight the helpful parts of the comment chain.
I'll try and take a look at that answer when I get a chance, I know I tried a bunch of things, but maybe not that one.

Like Stefan Salzl likes this
Robert Valentine August 8, 2022

That one didn't do it for me.
I think I need to be able to actively iterate through the multiselect for this process.

But the issue report is an answer.

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