Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Getting user profile element from User Profiles plugin

Lukasz Andrzejewski December 10, 2019

Hi

I am trying to somehow through scriptrunner postfunction pick a value of user profile  element created via this plugin https://marketplace.atlassian.com/apps/1212508/user-profiles-for-jira?hosting=server&tab=overview

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.data.TextBasedProfileElementData
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

@WithPlugin("de.communardo.jira.plugins.userprofile")

@PluginModule
UppProfileElementManager uppProfileElementManager
@PluginModule
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.

 

 

Cheers,

Nadine

Communardo Products

TAGS
AUG Leaders

Atlassian Community Events