User Properties reference in JIRA Automation Plugin

jabybit July 18, 2016

In Edit Issue Action, I want to set an Issue's Custom Field to the value stored in the Reporter's JIRA User Properties field.  I know how to reference a Custom Field. But how can I reference a JIRA User's Property?

Example

For example: User King Duke, has a property "customerid" set to 1234. I would like to use that value to set the Issue's Customer field to 1234.

image2016-7-18 18:18:56.png

 

Background

Basically, we're using JIRA Service Desk to handle Requests from customers. I would like to automatically assign the Issue's Customer field based on the reporter. And customers would like their respective teams to be able to view each others' Requests. Therefore, based on the Reporter value, I would like to automatically set the Issue's Customer (a custom field for Issue) and Participants.  The plugin Teams for JIRA Service Desk may accomplish all of this already. However, until we get approval for that plugin, we're trying to get an interim solution via JIRA Automation Plugin.

3 answers

0 votes
Matej K
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 25, 2016

Nice and extensive search for solution smile

I do not think it will work out of the box. The only thing which 'might' work without coding is using the "User Properties via JIRA Toolkit". Then you may be able to read a user property as a custom field (not sure if it will work as expected though, you'll need to test).

You can obviously extend the EditIssueAction source code (or add a new action) with necessary logic if you are familiar with JAVA.

Last option might be that you will use Groovy Script Runner to script the change you need (I am not sure if it supports UserPropertyManager).

0 votes
jabybit July 19, 2016

I think access to the User Properties requires class (import com.atlassian.jira.user.UserPropertyManager) which is not imported in the JIRA Automation Plugin.

https://answers.atlassian.com/questions/12161457/is-there-a-way-to-update-user-properties-via-api-or-script

0 votes
jabybit July 18, 2016

Update

I’ve tried to see if I can get to the value from tables or REST API, just to understand if there is a special column/property name. But not sure where that would lead me.

I’ve tried various properties and calls based on reading some other postings, but that hasn’t helped either.

If there aren’t any calls/methods to retrieve that value, then is JIRA Toolkit Plugin the intermediate answer?


User Properties via JIRA Toolkit

JIRA Toolkit Plugin mentions

 

User Property Field

A read-only custom field that displays a user property.

 

If that plugin were installed in our environment, would that make the User Properties accessible via Velocity Context aka JIRA Automation Plugin?

Wanted to ask before trying, just in case.

User Properties via Table

Based on this

https://answers.atlassian.com/questions/151905/what-database-table-keep-user-properties

It’s stored in a table of course, but how can that be accessed via JIRA Automation Plugin (Velocity Context)


User Properties REST API

Info. accessible via REST API Based on this

REST API Documentation (for our version of JIRA)

REST API Example URL and Parameter (JIRA docs)


Tried this

http://example.com/rest/api/2/user/properties?username=kingduke

FAIL, gives this only

{"keys":[]}


User Properties via calls

 

Based on this

 

https://thepluginpeople.atlassian.net/wiki/display/JEMH/Customize+Email+Templates#CustomizeEmailTemplates-UserProperties

Tried this

 

$userPropertyManager.getPropertySet($issue.reporter).getString("customerid") FAIL


Based on this

https://answers.atlassian.com/questions/46589/how-can-i-access-to-users-properties-from-a-velocity-context

Tried these

$issue.reporter.UserPropertyManager.getPropertySet() FAIL

$issue.getCustomFieldValue($customfield)

This is also the thread that recommended JIRA Toolkit.


Based on this

https://answers.atlassian.com/questions/169685/how-do-you-get-user-properties-to-be-sent-in-an-outgoing-email-issueassigned-vm


Tried these

$UserPropertyManager#getPropertySet(User).get("Phone")

$UserPropertyManager#getPropertySet(User).get("customerid") FAIL

$UserPropertyManager#getPropertySet($issue.reporter).get("customerid") FAIL

$UserPropertyManager.getPropertySet($issue.reporter).get("customerid") FAIL

$getPropertySet($issue.reporter).get("customerid") FAIL


Based on this

https://answers.atlassian.com/questions/35780988/can-i-report-based-on-user-properties

Tried these


  • $issue.reporter.displayname - fail

  • $issue.reporter - pass, kingduke(abc@gmail.com)

  • $issue.reporter.displayName - pass, King Duke

  • $issue.reporter.name - pass, kingduke

  • $issue.reporter.emailAddress - pass, abc@gmail.com

  • $issue.reporter.properties - fail

  • $issue.reporter.property - fail

  • $issue.reporter.customerid - fail

  • $issue.reporter.properties.keys - fail

  • $issue.reporter.properties.customid - fail


  • $issue.reporter.getDisplayName() - pass, King Duke

  • $issue.reporter.getPropertySet() - fail

  • $issue.reporter.getEmail() - fail

  • $issue.reporter.getEmailAddress() - pass, abc@gmail.com

  • $issue.reporter.getNumberOfReportedIssuesIgnoreSecurity() - fail

Suggest an answer

Log in or Sign up to answer