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

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Kurt Klinner
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 5, 2020

@Olga Videc 

 

Hi Olga,

i think a quick approach would be to use the rest api search method (https://developer.atlassian.com/cloud/jira/platform/rest/v3/?_ga=2.229594328.537028380.1580935661-787936783.1580935661#api-rest-api-3-search-get) in combination with a JQL query like 

created >= startOfMonth()

 

Will provide a little script tomorrow

 

Cheers

Kurt

TAGS
AUG Leaders

Atlassian Community Events