Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

a Scriptrunner Behavior with a issue picker field and a Insight referenced custom field

Marco Brundel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
March 24, 2021

Hi, I have a Scriptrunner Behavior who (on the service desk portal) has to take over the values ​​of an issue selected in an issue picker field in Insight Custom Fields. Only the value of an Insight referenced custom field is not taken over. 

This is the script. 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)
def issueManager = ComponentAccessor.getIssueManager() as IssueManager
def issuePickerCustomFieldValue = getFieldById(getFieldChanged()).value
def relatedIssue = issueManager.getIssueByCurrentKey(issuePickerCustomFieldValue as String)

def EngineerPACustomField = getFieldByName("Engineer E/PA")
def EngineerPACustomFieldObject = customFieldManager.getCustomFieldObjectsByName("Engineer E/PA")[0]
def EngineerPACustomFieldValue = (EngineerPACustomFieldObject ? relatedIssue.getCustomFieldValue(EngineerPACustomFieldObject) : null) as String
if (EngineerPACustomFieldValue) {
def objectKeyStr = EngineerPACustomFieldValue.substring(EngineerPACustomFieldValue.indexOf("(")+1,EngineerPACustomFieldValue.indexOf(")"))
EngineerPACustomField.setFormValue(objectKeyStr)
}
def SystemIntegratorCustomField = getFieldByName("System integrator")
def SystemIntegratorCustomFieldObject = customFieldManager.getCustomFieldObjectsByName("System integrator")[0]
def SystemIntegratorCustomFieldValue = (SystemIntegratorCustomFieldObject ? relatedIssue.getCustomFieldValue(SystemIntegratorCustomFieldObject) : null) as String
if (SystemIntegratorCustomFieldValue) {
def objectKeyStr1 = SystemIntegratorCustomFieldValue.substring(SystemIntegratorCustomFieldValue.indexOf("(")+1, SystemIntegratorCustomFieldValue.indexOf(")"))
SystemIntegratorCustomField.setFormValue(objectKeyStr1)
}
def MedewSystemIntegratorCustomField = getFieldByName("Medewerker System integrator")
def MedewSystemIntegratorCustomFieldObject = customFieldManager.getCustomFieldObjectsByName("Medewerker System integrator")[0]
def MedewSystemIntegratorCustomFieldValue = (MedewSystemIntegratorCustomFieldObject ? relatedIssue.getCustomFieldValue(MedewSystemIntegratorCustomFieldObject) : null) as String
if (MedewSystemIntegratorCustomFieldValue) {
def objectKeyStr2 = MedewSystemIntegratorCustomFieldValue.substring(MedewSystemIntegratorCustomFieldValue.indexOf("(")+1, MedewSystemIntegratorCustomFieldValue.indexOf(")"))
MedewSystemIntegratorCustomField.setFormValue(objectKeyStr2)
}

 "PA Project" is a Issue picker field.

"Medewerker System integrator" is an Insight referenced custom field and this is not copied from the chosen issue.

"Engineer E / PA" (User Picker (single user) field) and "System Integrator" (Insight Object/s field) are copied correctly.

How do I get this working?

regards, Marco

image.png

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
serge calderara
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 6, 2020

@Vincent Lee , did you find a way to make it work on your side because I have sam issue when using it under console editor within Jira.

The Intellisense seems to work when it wants to but most of the time it does not and I never get intellisense as explain in the doc.

Any new from yourside ?

regards

Vincent Lee
May 12, 2020

Hi @serge calderara ,

No, It still not work in my side.

Now I use IntelliJ to develp

regards

Katy Kelly
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 12, 2020

Hi, 

As we mentioned above, please follow the open bug report for this here: https://productsupport.adaptavist.com/browse/SRJIRA-4027

Kind regards,

Katy

0 votes
Katy Kelly
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
February 17, 2020

Hi, 

Please follow the open bug report for this here: https://productsupport.adaptavist.com/browse/SRJIRA-4027

Regards,

Katy

Adaptavist Product Support 

TAGS
AUG Leaders

Atlassian Community Events