Forums

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

Automation rule on referenced Insight objects

Arnaud Marquis April 26, 2022

On my issue type, I created a custom field to reference Insight objects.

When I update that issue field (when I add a reference to an Insight object) I want to automate the value of an attribute of the referenced Insight object.

My Insight object has an attribute called "Stock" and I would like to update that value to its own value, minus 1.

That is : my Insight object has a "Stock" value of 10. When I reference this object on my issue, I want to update that stock value to 10-1 (9).

image.png

The automation rule gets triggered, but the value of Stock becomes -1 instead of 9. I bet the problem is with "object.Stock". What am I doing wrong?

2 answers

1 accepted

1 vote
Answer accepted
Arnaud Marquis May 4, 2022

For the sake of completion, with the help of Atlassian support, I was able to generate the rule. I needed a Global Automation rule with the following settings:

  • When: Field value changed
    • Fields to monitor for changes: [Insight object field] 
    • Change type: Value added
  • Then: Create variable
    • Variable name: addedValues
    • Smart value: {{#addedfieldChange.values}}"{{.}}"{{^last}},{{/}}{{/}}
  • Branch on IQL
    • Schema: [Insight object schema]
    • Query: Name IN ({{addedValues}})
  • Then: Create variable
    • Variable name: stock
    • Smart value: {{object.Stock}}
  • And: Edit object attributes
    • Attribute: Stock
    • Value: {{#=}}{{stock}} - 1{{/}}

I created a reverse rule to increment the Stock value by 1 when an Insight object is removed from my field as well. It is basically the same rule but with {{#deletedfieldChange.values}} when "Change type" is "Value deleted".

It works as expected, when one (or more) Insight object(s) are added/removed from the field.

Markus Pöhler
Contributor
October 14, 2022

Hello @Arnaud Marquis 

saw your thread after I was looking for a solution to use the content of fields within object change triggers in insight.

Unfortunately, neither "When: Field value changed" nor "Then: Create variable" exists as options in the automation rules I can define.

2022-10-14 18_50_19-Insight - Athlon JIRA – Mozilla Firefox.png

What am I missing here?

0 votes
Gaurav
Community Champion
April 26, 2022

Hello @Arnaud Marquis 

This is an interesting use case. I have done something similar previously, but I was mainly extracting the data from the Insight schemas.

Looking at the rule, I think it is not able to point/ gather the exact 'Stock'. So the question is stock for what?

I believe you would have some other Custom Field where you would be storing the item whose stock would need to be depleted. Replace the word 'object' with that field name and try. It should work.

Please find below the screenshot of my implementation. Kindly accept the answer if this helps.

Regards,

GG

Insight Object.png

Arnaud Marquis April 26, 2022

@Gaurav thanks for your answer.

So the question is stock for what? - Stock (which is a custom Insight object attribute) of that specific referenced object. As I said, it "works" as it updates the stock value of the Insight object I am after. Just not with the right value.

I believe you would have some other Custom Field where you would be storing the item whose stock would need to be depleted. Replace the word 'object' with that field name and try. - No, there is no additional custom field. Just the attribute.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events