Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

222 views 2 1
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