Hi Everybody,
i try to write a Scriptrunner Scrip in a Postfunction (Creation of ISSUE) to set the Summary based on a Value which comes from an Insight Object.
Tried the following:
import customRiadaLibraries.insightmanager.InsightManagerForScriptrunner
import customRiadaLibraries.insightmanager.SimplifiedAttachmentBean
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.issue.priority.Priority
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)
def insightKey = getFieldByName("User").value //Used Custom field Name
def summary = getFieldById("summary")
def text = objectFacade.loadObjectBean(insightKey)?.label
summary.setFormValue("Request for ${text}")
But i always get this error:
2021-11-16 17:35:39,775 ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed on issue IAM-6 for user 'liha03'. View here: http://jira.aspecta.li:8080/secure/admin/workflows/ViewWorkflowTransition.jspa?workflowMode=live&workflowName=IAM%3A+Workflow+for+IAM+Order+%2F+Modify+Jira+Service+Desk&descriptorTab=postfunctions&workflowTransition=211&highlight=1
java.lang.NullPointerException: Cannot invoke method getFieldIdByName() on null object
at com.onresolve.jira.groovy.Behaviour$getFieldIdByName$2.call(Unknown Source)
at com.onresolve.jira.groovy.user.FieldBehaviours.getFieldByName(FieldBehaviours.groovy:71)
at Script137.run(Script137.groovy:11)
What am I doing wrong?
Thank you in advance.
Marco