Hello All,
There are some attributes that I am retrieving from Active Directory using Active Directory Attributes Sync 2 addon.
When I create an issue in JIRA, I am able to display the attribute details such as contact number, Department in the issue details screen. Now I want to write a server side script using script runner behaviour to get the value of the contact number and paste that value in another custom field of type text in JIRA. Is it possible to do so?
If it is, can you please assist me how to get this done?
Thanks.
Khushbu
Hi,
I was able use the information from the following site (example on the bottom) to show a reporters phonenumber in a customfield: https://deviniti.com/support/addon/server/active-directory/latest/using-synchronized-data-in-script-runner/
import com.atlassian.Jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.intenso.Jira.plugins.admanager.util.ActiveDirectoryAttributeManager
@WithPlugin("com.intenso.Jira.plugins.ad-integration-manager")
def activeDirectoryAttributeManager = ComponentAccessor.getOSGiComponentInstanceOfType(ActiveDirectoryAttributeManager.class)
def userManager = ComponentAccessor.getUserManager()
def reporteruser = myIssue.getReporter()
def user = userManager.getUserByKey(reporteruser)
def userAttributeMap = activeDirectoryAttributeManager.getUserAttributes(user, "myActiveDirectory") //get Map of user Attibutes for connection "myActiveDirectory"
def telephoneNumber = userAttributeMap.get("Telephone Number") //get Attribute from Map`
return telephoneNumber
Hope this will help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.