How to access {{rule.actor.properties.[custom_property]}} set in an Automation?

Jeremy Ens December 17, 2021

Use case:

I want to set a custom property that will increment each time a rule is executed, which can then be assigned to a custom field on all the tickets generated by the current automation execution. This property needs to be unique across all executions of the automation rule.

What has worked so far:

I have successfully implemented setting/getting an incrementing property using the {{reporter}}, {{assignee}}, and {{project}} entity properties. Reporter and Assignee won't be unique across all executions of the rule, and I don't want to use the project due to security concerns (I don't want to grant Project Admin rights to the user executing the automation).

Ideal solution:

I want to use the {{rule.actor}} entity's properties to "store" the incrementing variable.

Problem:

For some reason, I cannot access the custom property {{rule.actor.properties.[custom_property]}} from within the automation. I have tried every variation of the smart value expression that I can think of, but the smart value always returns null. Note - I know the rule.actor's user's property is being set, as I can see the property and correct value using the Jira REST API.

Has anyone successfully done something like this?

1 answer

1 accepted

0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2021

Hi @Jeremy Ens -- Welcome to the Atlassian Community!

First thing: I do not have an answer to your question.

Instead...I am curious what REST API method you used to access a property of an automation rule.  My understanding is the REST API for manipulating rules doesn't exist yet.

Thanks, and kind regards,
Bill

Jeremy Ens December 20, 2021

Hey Bill, 

Darn, that is unfortunate to hear. Perhaps someone else will have some insight.

To answer your question - I am not using the REST API to access a properties of the automation rule itself; I am using the REST API via web browser to view properties of the entities used by the rule. The endpoints I've been using are:

  • api/2/issue/{issueIdOrKey}/properties/{propertyKey}
  • api/2/project/{projectIdOrKey}/properties/{propertyKey}
  • api/2/user/properties/{propertyKey}

From within the automation itself I am using the "Set Entity Property" component to set entity properties and then later accessing those properties using smart values.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2021

Thanks for explaining that, Jeremy.

Is the specific user you want to update the person (user) who triggered the rule?  If so, that can be found with the smart value {{initiator}}

Jeremy Ens December 20, 2021

No, I want the user that is actually executing the rule; the user that is selected in the "Actor" field of an automation rule as seen under "Rule Details".

Note: {{rule.actor}} does return the expected user entity, and I am able to access the normal properties of the user (ex: {{rule.actor.displayName}} will return the expected value). The issue is that {{rule.actor.properties.[custom_property]}} returns null, even though I can confirm the property is set, as per the api endpoints I listed above.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2021

I believe this open defect is what you are seeing: https://codebarrel.atlassian.net/browse/AUT-1886

Unfortunately that one is in the Code Barrel backlog so we cannot watch it for progress.

Jeremy Ens December 20, 2021

Ah, that does appear to be the likely culprit. Thank you for providing me with this information. It looks like I will not be able to use the {{rule.actor}} and will need to use another approach.

Thanks Bill for your time and effort!

Like Bill Sheboy likes this
Jacob Kang December 29, 2021

Hi Jeremy, 

Just want to know your progress on this matters....seems i encountered the same issue as yours. 

I want to use smart value to get one custom value of user that create via "user>>details>>edit jira properties" and unfortunately there is no way to get it.

Please let me know if you solved it.

 

Thanks

Jeremy Ens January 4, 2022

Hey Jacob,

My solution did not use properties that are set/managed by Jira's configuration/administration screens. My solution used smart values inside the automation itself. It sounds like what you are trying to do is quite different from my approach, so I am not sure I can provide much help.

That being said, I will try to explain the solution I came up with, and maybe something there will help you or others who stumble across this thread.

 

I ended up using the initiator user's properties to store the value, and then used a combination of that value plus the initiator user's key value to create a "unique" label to apply to all the issues created in the current run. That label is used for later grouping/processing during the current automation execution context.

I used the Set user property component on the initiator, using the following configuration example values:

  • User: {{initiator}}
  • Property key: automationid
  • Property Value: {{#=}}{{initiator.properties.automationid}}+1{{/}}
    • note: {{#=}}{{/}} will make everything inside it a math expression, which provides the desired incrementing behavior on the automationid property

This value is then added to the triggering issue using the triggering issue via the Set Issue property component, with the configuration values:

  • Entity Type: Issue
  • Property key: automationid
  • Property value: {{initiator.properties.automationid}}

This value is then used in conjunction with the {{initiator.key}} value to create the "unique" label that is used by the Create a new issue component in the labels field.

The label ended up looking something like this:

  • {{initiator.key}}-AutomationId-{{triggerIssue.properties.automationid}}

The label is used for group processing via the For JQL component, where the JQL looks something like:

  • labels = {{initiator.key}}-AutomationId-{{triggerIssue.properties.automationid}}

The final step in the automation is removing the label from all the tickets using the Edit Issue component within the context of the For JQL component described above.

Pseudocode:

When: {issue triggers this automation}}
If: {issue meets some conditions}
Then: Set user property automationid
And: Set issue property automationid
If: {some other condition is matched}
  Then: Create a new issue with unique label}
For JQL: {labels = unique label}
  {do stuff}
  Then: Edit issue fields (labels): {remove unique label}

I hope this helps!

Like Bill Sheboy likes this
Brent Jenkins March 3, 2023

@Bill Sheboy or @Jeremy Ens :
Sorry for reviving an old thread, but can you copy/paste or summarize the bug you discussed above in this thread at:  https://codebarrel.atlassian.net/browse/AUT-1886

In an automation rule, I can store and retrieve a user entity property using {{assignee}}.  However, if I try setting a variable in the automation rule to = {{assignee}} and then use that variable to retrieve the property, it doesn't work.  I'm wondering if that bug has something to do with it, and has a workaround?

For example:
{{assignee.properties.myProperty}} retrieves the value just fine.

But, create a variable:
{{myAssignee}} = {{assignee}}

And try to retrieve the same property as so:
{{myAssignee.properties.myProperty}} always returns null.

If I log the values for {{assignee}} and {{myAssignee}} they appear identical.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 3, 2023

Hi @Brent Jenkins 

Would you please post images of your complete rule and the audit log details showing the rule execution?  Those may provide context for what you are observing.  Thanks!

Until those images are posted...here are some other thoughts:

I do not believe the old Code Barrel backlog is available/accessible any longer.  Instead the Atlassian team is using the AUTO project in the public backlog.  (I believe I saw a community post on this change.)  And so...I do not know what was in that old issue, AUT-1886

Next, referencing a property looks up that value for the object.  And created variables are text-type; they are no longer the source object-type.  As a result you cannot use a created variable as an alias to a field (or other) issue object.

What problem are you trying to solve by treating a created variable as an alias to an issue field?

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer