Hi community!
With help of ScriptRunner I created custom filed(Text Field multi-line) that shows the user properties of the issue reporter
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.UserPropertyManager
UserPropertyManager userPropertyManager = ComponentAccessor.getUserPropertyManager()
String propValue = null
propValue = userPropertyManager.getPropertySet(issue.reporter).getString('jira.meta.More')
return propValue
Is it possible to add a function for changing properties in this field, and how can this be done?
I have little knowledge in Scriptrunner, Thanks in advance.
Hi @Vladimir Fed ,
A. If I understood it correctly, you want to save the reporter's user property in your newly created custom field?
OR
B. Whatever the value of the newly created custom field it will save it to the user property of the issue reporter?
Hi @brbojorque
Probably option B
Now the custom field returns the user properties that I added in user management (ex. Key = More)
I want the user’s properties to be changed through the current custom field and saved, even if they are already specified there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vladimir Fed ,
Here's the ScriptRunner Listener code
Remove the old custom field and create a new custom field from Jira.
Make sure it will listen to Issue Created and Issue Updated
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.UserPropertyManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.ApplicationUser
UserPropertyManager userPropertyManager = ComponentAccessor.getUserPropertyManager()
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userPropertiesField = customFieldManager.getCustomFieldObjectByName("User Properties") //Multi line custom field
MutableIssue issue = (MutableIssue) event.issue
//Saving the property Preferences
userPropertyManager.getPropertySet(issue.reporter).setString('jira.meta.more', issue.getCustomFieldValue(userPropertiesField) as String)
//Reading the property
String propValue
propValue = userPropertyManager.getPropertySet(issue.reporter).getString('jira.meta.more')
//Saving the property to Custom Field
issue.setCustomFieldValue(userPropertiesField, propValue)
ApplicationUser applicationUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueManager.updateIssue(applicationUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
Out of curiosity what is the reasoning behind this requirement?
-
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, @brbojorque
Thanks a lot, but code doesn't work.
These are support B2B requirements for Service Desk.
They need the ability to change the contact details of customers, provided that they have the rights of only an SD agent
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vladimir Fed ,
You can't actually change the User data by just changing the preferences.
E.g Username, Last name, first name.
I believe this solution is not for you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.