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:
- in the GUI (Edit Properties) we added and set a user property (key: prop1, value: value1)
- this property is stored persistent in Jira, even over several browser sessions
- we try to read this property with our script (see below) but we fail as you can see in the generated output (bottom)
- with the script we set another property (key: prop2, value: value2), which seems to be available in the script only, but not persistently stored ti Jira (not accessible by GUI)
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