Retrieve Project Property and copy to custom field

Daniel Eads Community Champion Jul 20, 2016

We're sending a string to JIRA from another application and storing in a project property ( https://docs.atlassian.com/jira/REST/latest/#api/2/project/{projectIdOrKey}/properties-getPropertiesKeys ). How do you retrieve a property like this in a Scriptrunner post-function and store it in a custom field?

I've seen examples that use curl to make GET calls, but this seems a little silly because the data is already in JIRA (plus it also seems like bad practice to store a password in a workflow post function).

We're on JIRA 6.4 still. I see that there are ready-made postfunctions that can read user properties, but the API method for setting these from another application wasn't introduced until JIRA 7.

1 answer

Most of the APIs for interacting with custom project properties are in the com.atlassian.core.ofbiz.util package.

The OFBizPropertyUtils class has a getPropertySet method (and more preferred getCachingPropertySet method) that retrieves those sort of values. I've yet to find an example for getting the GenericValue argument that doesn't utilize a deprecated method at some level, so you might prefer the other method signature that takes a string and a long.

If not, the Project class has a deprecated getGenericValue() method that you can use to retrieve the needed Generic value argument. There's also GenericDelegatorUtils class, which can get you a GenericDelegator with. From there,

def gv = genericDelegator.findByAnd("Project", ["id": projectId as Long])?.first()

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,128 views 13 19
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot