Forums

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

How do I access a User entity's properties (set via API)?

Alex van Vucht (GLiNTECH)
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 15, 2016

Hi! I love Code Barrel's Automation plugin.

Now, I can set user properties via API:

curl -D- -d'"VIP User"' -u admin:<password> -X PUT -H "Content-Type: application/json" https://<My JIRA Cloud>.atlassian.net/rest/api/2/user/properties/vip?username=admin

And I can similarly retrieve them:

curl -D- -u admin:<password> -X GET https://<My JIRA Cloud>.atlassian.net/rest/api/2/user/properties/vip?username=admin

 

In the Automation plugin, I can retrieve many Reporter's details, eg., if the Reporter is admin, then I can set the Reporter Username custom field this way:

{
    "fields": {
        "Reporter Username": "{{issue.reporter.name}}"
    }
}


It makes sense to me that this should work, to set a VIP User custom field:

{

    "fields": {
        "VIP User": "{{issue.reporter.properties.vip}}"
    }
}

However this doesn't work. How do I access the "vip" property I set on the user entity in the JIRA Automation plugin?

3 answers

1 accepted

3 votes
Answer accepted
Nick Menere
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.
August 6, 2017

This can be done with the simple format:

{{issue.reporter.properties.vip}}

 

If you area trying to access the properties that are set via UI in user managgement (these are not entity properties but rather a legacy feature in JIRA) you can do the follwoing in Server only:

{{issue.reporter.legacyProperties.vip}}

 

Cheers,

Nick

Vaishali Patil
Contributor
February 9, 2021

I am facing a problem where I want to check the value of entity property in an automation rule like such:

"{{issue.reporter.properties.JobRole}}"="{name=QE}"

but I always get the error of:

 ("{name=QE}"="{name=QE}")" - Field '{name=QE}' does not exist or you do not have permission to view it.

It always evaluates the property. I am setting the property via the rest api.

Darryl Lee
Community Champion
February 10, 2021

@Vaishali Patil So your entity property is JobRole? It would be helpful if you could show the JSON of the property. This tool would allow you to display it:

https://marketplace.atlassian.com/apps/1214509/entity-property-tool-for-jira

(Caveat: You don't want to leave it enabled - it shows the entity properties to all users, which can be confusing.)

Without being able to see the property, I'm going to guess that maybe what might work is:

{{issue.reporter.properties.JobRole.name}} = "QE"

Or this should also work:

{{reporter.properties.JobRole.name}} = "QE"

References:
https://support.atlassian.com/jira-software-cloud/docs/smart-values-users/

Vaishali Patil
Contributor
February 11, 2021

@Darryl Lee I figured out what I was doing wrong. I was using jql instead of 'advanced compare condition. It started working when I switched it.

I tried the entity-property tool but it wouldnt work for user. It worked only for issue.  Btw, we can see the properties by browsing to 

https://your-domain.atlassian.com/rest/api/3/user/properties/{propertyKey}?accountId={accountId}

The value is stored as json so the value for me was {name=QE} 

Like Darryl Lee likes this
2 votes
Nick Menere
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 16, 2016

Hi Alex,

Unfortunately this can't be done yet, though it something we will DEFINITELY add - https://codebarrel.atlassian.net/browse/AUT-83

It would really help a lot of use-cases. Watch the issue and we will try to get to it soon.

 

Cheers,

Nick

0 votes
krnaicker
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 5, 2020

Has anyone gotten a solution for this?

I'm trying to access a property value within Automation however no value is retrieved using any of the formats suggested above.

Is there any other way in a automation action or condition i can utilize user property 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.
August 6, 2020

Hey @krnaicker  -- Welcome to the Atlassian Community!

After a bunch of tinkering, I finally got this to work in an automation rule:

{{issue.properties."myNameSpaceExample.myKey"}}

The values I used when I Set Entity Property were:

  • Entity Type: Issue
  • Property Key: myNameSpaceExample.myKey

This didn't match any of the documented examples I found thus far; they either had no quotation marks or had them in different locations..  I still cannot get access to the property via JQL.  I am starting to wonder if this feature is still experimental.  :^)

 

Best regards,

Bill

Like Rabbit Stoddard likes this
Darryl Lee
Community Champion
August 24, 2020

Hey Bill, there's a bit in the docs for Entity properties here that says:

How do I make the properties of an entity searchable?

Jira Server plugins can provide a module descriptor that will make the issue properties searchable using JQL.

https://developer.atlassian.com/server/jira/platform/entity-properties/

So... I guess it works if you're creating a plugin.

Here's details on that module for cloud:

https://developer.atlassian.com/cloud/jira/platform/modules/entity-property/

Darryl Lee
Community Champion
August 24, 2020

Oh, and I completely neglected to thank you for the tip on putting the key in quotes.

By the way, it turns out you can ALSO load a whole JSON object into an entity, like so:

{ "App1" : "assigneeid1",
"App2" : "assigneeid2",
"Some App" : "assigneeid3"}

I set the above as the value for a Project Entity Property key subtaskAssignees using an Automation rule.

And then I was able to reference individual keys thusly:

{{project.properties.subtaskAssignees."App1"}}

Now... if I could just figure out how to iterate through a list of Checkbox values and create Subtasks that are assigned according to that mapping, with Summaries based on the Checkbox values, then we'd be in business. :-}

https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Create-Sub-Tasks-from-User-Selection-on-Multi-Value-Checkbox/qaq-p/814856

Like # people like this

Suggest an answer

Log in or Sign up to answer