Hello there.
One of my customer is using Script Runner Behaviors for dynamic forms and for prefilling data to various fields based on current user.
Mainly:
We dont know what exactly happened, code is little bit old, but right now customer figured out, that it wont work, if the user is logged in as the customer.
I tried it, reproduce it with 100% success. As service desk or software or core user, everything works.
As customer, neither current user or manager and other fields are populated.
Any idea where it could be wrong? Probably happened with some Script Runner or Insight upgrade, but noone noticed for a while ...
import com.atlassian.jira.component.ComponentAccessor
// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Get the Requestor field
def requestor = getFieldById("customfield_10401")
if (requestor.formValue == "")
{
requestor.setFormValue(currentUser.key)
}
// change this to ID of schema, where IQL should search for objects
def schemaID = 3
// change this to name of field, where Phone number should be stored
def phoneField = getFieldByName("Contact number")
// change this to name of field, where Manager should be stored
def managerField = getFieldByName("Manager or supervisor (approver)")
// change this to name of attribute in Insight, where phone number is stored
String attributeManager = "User Manager"
// change this to name of attribute in Insight, where phone number is stored
String attributePhone = "Mobile Phone"
// change this to name of attribute in Insight, where user key is stored
String attributeUserID = "Employee ID"
if( getFieldById(getFieldChanged()).getValue() )
{
// Get Insight IQL Facade from plugin accessor
Class iqlFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade")
def iqlFacade = ComponentAccessor.getOSGiComponentInstanceOfType(iqlFacadeClass)
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)
def userKey = getFieldById(getFieldChanged()).getValue().toString()
def objects = iqlFacade.findObjectsByIQLAndSchema(schemaID, "\"" + attributeUserID + "\" = \"" + userKey + "\"")
int objectId = objects[0].getId()
def objectPhone = objectFacade.loadObjectAttributeBean(objectId, attributePhone)
if( objectPhone )
{
def objectAttributeValues = objectPhone.getObjectAttributeValueBeans()
def objectAttributeValue = objectAttributeValues[0]
phoneField.setFormValue(objectAttributeValue.getValue())
}
else
{
phoneField.setFormValue(null)
}
def objectManager = objectFacade.loadObjectAttributeBean(objectId, attributeManager)
if( objectManager )
{
def objectAttributeValues = objectManager.getObjectAttributeValueBeans()
def objectAttributeValue = objectAttributeValues[0] // object ID
def objectManagerRef = objectFacade.loadObjectAttributeBean(objectAttributeValue.getValue(), attributeUserID)
if( objectManagerRef )
{
objectAttributeValues = objectManagerRef.getObjectAttributeValueBeans()
objectAttributeValue = objectAttributeValues[0]
managerField.setFormValue(objectAttributeValue.getValue())
}
else
{
managerField.setFormValue(null)
}
}
else
{
managerField.setFormValue(null)
}
}
else
{
phoneField.setFormValue(null)
managerField.setFormValue(null)
}
Insight 8.4.3
Script Runner 5.9.1-p5
Jira Software 8.5.1
Jira Service Desk 4.5.1
Thanks for any ideas
UPDATE:
With support we found out the the issue is caused most probably by documented bug at https://productsupport.adaptavist.com/browse/SRJIRA-3918
Hi Tomas,
Did you check in the schema configuration in the roles section if if the Object Schema Users permissions for Service Desk Customers are enabled?
Br,
G
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
With support we found out the the issue is caused most probably by documented bug at https://productsupport.adaptavist.com/browse/SRJIRA-3918
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.