Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script Field throwing Marshalling Exception on Issue Creation

Script gods, 

I have created a short script field that looks up values from an issue picker field to display to the user in forms and reports. This seems to work well enough except for issue creation where it's throwing a serializer error - although the issue is still properly created.

This is the script:

import com.atlassian.jira.component.ComponentAccessor


def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

//lookup the Feature Group value from the Feature issue then get the Feature Group issue object
def fgField = customFieldManager.getCustomFieldObjectByName("Feature Group")
def fgIssueKey = issue.getCustomFieldValue(fgField).toString()
def fgIssue = issueManager.getIssueObject(fgIssueKey)

//get the Context value from the Feature Group issue object
def context = customFieldManager.getCustomFieldObjectByName("Context")
def contextValue = fgIssue.getCustomFieldValue(context);

//return the value to the script field
return contextValue

this is the error: 

Exception occurred: com.atlassian.plugins.rest.common.json.JsonMarshallingException: org.codehaus.jackson.map.JsonMappingException: No serializer found for class com.atlassian.jira.issue.customfields.option.LazyLoadedOption and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.atlassian.jira.quickedit.rest.api.field.QuickEditFields["createdIssueDetails"]->com.atlassian.jira.rest.v2.issue.IssueBean["fields"]->java.util.HashMap["customfield_17317"])

any help would be greatly appreciated!

 

1 answer

1 accepted

0 votes
Answer accepted

Is your "Context" field a single select by any chance?

Is so, the contextValue is returned as "LazyLoadedOption".

So try to return like this:

return contextValue?.value

@Peter-Dave Sheehan that did the trick!  thank you. I made a couple other updates to get rid of the static type errors and my final script looks like this: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

//lookup the Feature Group value from the Feature issue then get the Feature Group Issue
def fgField = customFieldManager.getCustomFieldObjectByName("Feature Group")
def fgIssueKey = issue.getCustomFieldValue(fgField).toString()
def fgIssue = issueManager.getIssueObject(fgIssueKey)

//get the Context value from the Feature Group issue
def contextFld = customFieldManager.getCustomFieldObjectByName("Context")
def contextValue = getCustomFieldValue(contextFld) as LazyLoadedOption;

//retrun the value to the script field
return contextValue?.value

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

216 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you