I need help creating a script for the Script Runner Plugin and a custom Scripted Field.
Custom Form - Helpdesk
(Custom User Picker Field) Customer <--- information is from the Jira Users
(Scripted Field) Users Location
I need help creating a script that will pull data from User Properties. In User Properties I have created several keys (public Location, public Address, public Phone, etc)
I need the Scripted Field to pull the public Location properties and disaplay it in the field.
Thanks in advance,
Andre
Community moderators have prevented the ability to post new answers.
Try this in your testsystem:
import com.atlassian.crowd.embedded.api.User import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.UserPropertyManager UserPropertyManager userPropertyManager = ComponentAccessor.getUserPropertyManager() String propKey = "propertykey" String propValue = null User u = getCustomFieldValue('Customer') if (u) { propValue = userPropertyManager.getPropertySet(u)?.getString('jira.meta.'+propKey) } return propValue
You first have to adapt propKey to the property key you want to get.
Henning
Hi!
The code is great and simple but is didn't work for me because our users are from Active Directory.
The error in that case is:
Cannot cast object '***' with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User' dded.api.User'
So I fixed it by adding a different user type as follows:
import com.atlassian.jira.user.DelegatingApplicationUser .. .. DelegatingApplicationUser u = getCustomFieldValue('Customer')
I hope my comment will help someone sometime somewhere...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Tamir Lavi.
It helped me a lot.
I wonder is there any way to display this property but not from User from field but current user?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure, just use
u = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser()
instead of
u = getCustomFieldValue('Customer')
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.
I have tried the following script, however it is not working at all.
import com.atlassian.jira.web.action.admin.user.UserProperty;
import com.atlassian.jira.user.util.Users;
import com.atlassian.jira.issue.Issue;
String s="";
if getCustomFieldValue(11102)=Users()
{
s=s+getValue('public Location');
}
return s;
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.