we have object type "user" with attribute "name" and attribute "user jira" (type user)
we would like to assign attribute "user jira" automatically based on mapping "user"."name" = username of "user jira"
manual assignement works but we would like to automate it.
can someone help me please. thank you.
Can you provide a bit more context around this operation?
Are your user objects populated automatically with some import?
Or are you looking to create user objects manually by providing the username in the user.name attribute and have the "user jira" attribute automatically populated after saving so that object creators don't have to enter the same value twice?
yes, your second assumption is correct. populated on save and for existing objects. we have a a lot of user objects which must be connected to jira users (jira users are imported via ldap).
(further step could be create user objects also via ldap import)
thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you have your user object type connected to LDAP Import, you could just map the ldap attribute that contains your username to both the "name" and the "user jira" insight attribute and all the existing objects will be refreshed with the jira account.
You don't need to use automation for it.
To have 1 field populated on the basis of another one on the create or update event requires a groovy script.
Here is something I cobbled together from other existing scripts I have:
import com.atlassian.jira.component.ComponentAccessor
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean
import com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeBean
import com.riadalabs.jira.plugins.insight.services.events.EventDispatchOption
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectFacade)
def objectTypeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectTypeFacade)
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectTypeAttributeFacade)
def ATTRIBUTE_NAME_NAME = 'Username'
def ATTRIBUTE_NAME_JIRA = 'Jira Account'
def objectType = objectTypeFacade.loadObjectType(object.objectTypeId)
doNameRefresh = true
if (this.binding.variables.containsKey('objectUpdateList')) {
doDateRefresh = this.binding.variable['objectUpdateList'].any {
it.attributeName in [ATTRIBUTE_NAME_NAME, ATTRIBUTE_NAME_JIRA]
}
}
if (doNameRefresh) {
def nameAttributeBean = objectTypeAttributeFacade.findObjectTypeAttributeBeans(objectType.id).find {
it.name == ATTRIBUTE_NAME_NAME
}
if (!nameAttributeBean) {
log.error "Unable to find attribute with name: $ATTRIBUTE_NAME_NAME"
return
}
def jiraUserAttributeBean = objectTypeAttributeFacade.findObjectTypeAttributeBeans(objectType.id).find {
it.name == ATTRIBUTE_NAME_JIRA
}
if (!jiraUserAttributeBean) {
log.error "Unable to find attribute with name: $ATTRIBUTE_NAME_JIRA"
return
}
def name = object.getObjectAttributeBeans().find {
ObjectAttributeBean it -> it.objectTypeAttributeId == nameAttributeBean.id
}.getObjectAttributeValueBeans()[0].value
def jiraAttrVals = object.getObjectAttributeBeans().find {
ObjectAttributeBean it -> it.objectTypeAttributeId == jiraUserAttributeBean.id
}?.getObjectAttributeValueBeans()
def jiraAttrVal = jiraAttrVals ? jiraAttrVals[0].value : null
def jiraUser = ComponentAccessor.userManager.getUserByName(name as String)
if (!jiraUser) {
log.error "Unable to find jira user with name $name"
return
}
if (jiraAttrVal != jiraUser.key) {
def newJiraAttr = object.createObjectAttributeBean(jiraUserAttributeBean)
def newJiraAttrVal = newJiraAttr.createObjectAttributeValueBean()
newJiraAttrVal.setValue(jiraUserAttributeBean, jiraUser.key)
newJiraAttr.setObjectAttributeValueBeans([newJiraAttrVal])
objectFacade.storeObjectAttributeBean(newJiraAttr, EventDispatchOption.DO_NOT_DISPATCH)
}
}
You just need to adjust ATTRIBUTE_NAME_NAME and ATTRIBUTE_NAME_JIRA save the script in your jira-home directory, add the script to the insight whitelist and then create an Insight automation that fires on create and update and has this script as the action.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@PD Sheehan Are you saying I can create a Schema in Insight with 'Email' and 'Username' and then bring that is from Okta to JSM somehow? I am trying to find a way to bind assets being imported where one of the keys is primary user email and then linking that to the customer in JSM so I can display the assets on the portal and incidents.
Basically I am just trying to have something in Insight that can link from imported assets, to the JSM email address for customers to bind it all together.
The email is in JSM - the email is in our asset system that gets imported into Insight, I just can't see how to join them together.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've never used Okta, but a quick google search shows that they have an LDAP agent that can convert LDAP calls to their API.
So yes, if you create a User schema, you can import all your identity information from OKta.
As part of that schema, if you have an attribute of type "User" you can map any Okta attribute that maps to your jira users's "username". This will create a link between those user objects and the internal jira users.
You can only map jira user via the username.
Then in your asset schema, it should be possible to link to another object type (the one containing the users).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found we have the email available in our asset import that matches the email in Jira, I think its just my lack of understanding of insight on how to bind an imported email address to matching internal jira customer emails.
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.