Hello, we are using Jira Server 7.11 with ScriptRunner installed.
Now we want to setup some ScriptRunner/Groovyscripts working with user properties, but we fail in consistent (Java API vs. GUI) & persistent handling of the properties.
Example:
Our code looks like this:
import com.atlassian.jira.component.ComponentAccessor
def userName='user1'
// get the application user
def userObject = ComponentAccessor.getUserManager().getUserByKey(userName)
// get property manager
def propMan = ComponentAccessor.getUserPropertyManager()
// get property set
def propSet = propMan.getPropertySet(userObject)
// read already (by GUI) set property
log.warn("prop1:"+propSet.getString('prop1'))
// set another property ...
propSet.setString('prop2','value2')
// and try to read it
log.warn("prop2:"+propSet.getString('prop2'))
The generated output is this:
2019-06-05 07:49:20,594 WARN [runner.ScriptRunnerImpl]: prop1:null
2019-06-05 07:49:20,598 WARN [runner.ScriptRunnerImpl]: prop2:value2
However, the property set by the script is NOT visible by GUI.
Can anyone point out what we are doing wrong?
Might this be caused by the fact, that we only tried it within the ScriptRunner's "Script Console" instead of a real REST endpoint or workflow script?
Thanks for your help
Klaus
Hello @Klaus Foerschl
All GUI properties have a hidden prefix "jira.meta", so you can get it like this
log.warn("prop1:"+propSet.getString('jira.meta.prop1'))
And if you want properties to be displayed, you should create it with prefix
propSet.setString('jira.meta.prop2','value2')
Hi Mark. That was easy. Thanks a lot for the instant and well working hint.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You re welcome! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.