Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

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.

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}}

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.

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.

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

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

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Do you use Jira Cloud with Microsoft Teams?

Hi, Jira users! Do you use Jira alongside Microsoft Teams? We want to hear how you’ve used the power of Jira Cloud and Microsoft Teams (via the Jira Cloud for Microsoft Teams app) to achieve a team...

317 views 1 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you