Getting user profile element from User Profiles plugin

Lukasz Andrzejewski December 10, 2019


I am trying to somehow through scriptrunner postfunction pick a value of user profile  element created via this plugin

Cannot find any proper method for this except by wrtiting a direct sql to database where this object is stored. Can anyone help?

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Oleksandr Kurtanych January 31, 2024

Hi @Lukasz Andrzejewski ,
You may have solved your issue a long time ago, but it may still help someone I hope))

In this script, I take the value of the text element from the Profile called (example) Department

import com.atlassian.sal.api.user.UserKey
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import de.communardo.atlassian.plugins.userprofile.external.api.model.elements.TextBasedProfileElement
import de.communardo.atlassian.plugins.userprofile.external.api.service.UppProfileElementDataManager
import de.communardo.atlassian.plugins.userprofile.external.api.service.UppProfileElementManager

import static com.atlassian.jira.component.ComponentAccessor.getJiraAuthenticationContext


UppProfileElementManager uppProfileElementManager
UppProfileElementDataManager uppProfileElementDataManager

def reporter = new UserKey(getJiraAuthenticationContext().getLoggedInUser().getKey())

TextBasedProfileElement textbasedProfileElement = uppProfileElementManager.getProfileElement(1);

TextBasedProfileElementData data = uppProfileElementDataManager.getProfileElementData(reporter, textbasedProfileElement);

def departmentData = data.getText()

Please take into account that you need to change your int .getProfileElement(1) acording to your ProfileElement ID

Best regards

0 votes
Nadine Schurz January 13, 2020

Hello Lucas,

you can get (reading) access to profile elements when you map them to custom Jira fields as described in our documentation. Is this what you are looking for?

If you are looking for an API access this feature is not part of User Profiles for Jira.





Communardo Products

AUG Leaders

Atlassian Community Events