Getting Jira User Properties in the HAPI way

Alexander Mateasik
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!
June 6, 2023

Hi, 

i get the additional properties of a user/reporter in the normal way like 

 

import com.atlassian.jira.component.ComponentAccessor

def userPropertyManager = ComponentAccessor.userPropertyManager

def reporter = issue.getReporter()
def reporterProp = userPropertyManager.getPropertySet(reporter).getText("MY_PROPERTIE")

 

Is there a HAPI Way to do this?

Maybe like this ?

Issues.getByKey('ABC-01').reporter.getProperties('MY_PROPERTIE')

2 answers

1 vote
Jamie Echlin _ScriptRunner - The Adaptavist Group_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 16, 2023

Hey..

Not currently, but we can add that in. Easy access to user and issue properties sounds like a good suggestion.  I've added a placeholder ticket here https://productsupport.adaptavist.com/browse/SRJIRA-6713 which you can watch.

cheers, jamie

0 votes
Graham Twine
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.
June 6, 2023

Hello @Alexander Mateasik ,

Welcome to the community.

 

I do not see a way to  get a property by key.

Issues.getByKey('ABC-01').reporter.properties returns a Map so one can get values off the map with the key

 

def value = Issues.getByKey('ABC-01').reporter.properties.get('KEY'

 

You can check what keys are available in the script console with

 

return Issues.getByKey('ABC-37').reporter.properties.keySet()

//returns in my instance [ID_COMPARATOR, key, user, bridgedUser, id, active, class, directoryId, directoryUser, displayName, emailAddress, name, username]
Jamie Echlin _ScriptRunner - The Adaptavist Group_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 16, 2023

This is a bit different... `.properties` in this case is `org.codehaus.groovy.runtime.DefaultGroovyMethods#getProperties` which will list all the "properties" of the object, but in the java sense of the word properties, rather than in the sense of `com.opensymphony.module.propertyset.PropertySet` which I believe Alexander is talking about.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events