Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Set Summary Based n Insight Custom Field in a Post function

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("")
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:
java.lang.NullPointerException: Cannot invoke method getFieldIdByName() on null object
	at com.onresolve.jira.groovy.Behaviour$getFieldIdByName$ Source)
	at com.onresolve.jira.groovy.user.FieldBehaviours.getFieldByName(FieldBehaviours.groovy:71)

What am I doing wrong?

Thank you in advance.


1 answer

1 accepted

0 votes
Answer accepted

Disclaimer: I've used Scriptrunner in the past but don't have access to it now. My information is coming from reviewing the documentation.

The getFieldByName and getFieldIdByName functions apply to getting data from a Form. When you are in a Post Function, any Form associated with the transition is no long available.

In your function I believe you need to reference the issue against which the transition is occurring.

Here is one example. Others can be found by doing an internet search for "jira scriptrunner groovy set value in post function"

Perfect, thank you!

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events