JsonMarshallingException when using scripted field on view screen

Hello,

we have a scripted field on a view screen that calculates the centralized release version based on the version entered in the issue.

 

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def searchProviderFactory = ComponentAccessor.getComponent(SearchProviderFactory)
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.getIssueManager()

def customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField managedRelease = customFieldManager.getCustomFieldObject("customfield_11801");

def builder = JqlQueryBuilder.newBuilder().where().defaultOr()
def clauseBuilder = JqlQueryBuilder.newClauseBuilder().defaultAnd()
clauseBuilder.project(issue.getProjectObject().getId());

if(issue.getFixVersions() == null || issue.getFixVersions().size() < 1)
	return "";

clauseBuilder.fixVersion(issue.getFixVersions().iterator().next().getName());
clauseBuilder.issueType("10402");
builder.addClause(clauseBuilder.buildClause())

def query = builder.buildQuery()
def result = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter());

if(result.getIssues().size() > 0)
	return result.getIssues().get(0).getCustomFieldValue(managedRelease);
else
    return "";

the script works fine, it executes without errors. However when creating a new issue, Jira 7.3.5 (previously 7.1.9 worked fine) throws the following exception

 

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_12601"])
 at com.atlassian.plugins.rest.common.json.DefaultJaxbJsonMarshaller.marshal(DefaultJaxbJsonMarshaller.java:57)

 

the mentioned custom field is the ID of the scripted field above.

We have no searcher configured as it is only a display field. Is there any way to avoid the exception?

1 answer

This widget could not be displayed.

Hi Stefan,

I have been looking into your issue, and I have tried your script on Jira version 7.3.5 and it seems to run without porblems. I do have some questions that might help get to the bottom of your issue.

You mentioned "the mentioned custom field is the ID of the scripted field above.", however if I set the custom field ID to that of the scripted field (CustomField managedRelease = customFieldManager.getCustomFieldObject("customfield_11801")), I get a StackOverflow error because essentially the script is retrieving its own value. It works for me when I reference a different (text field) custom value on that line instead. Can you maybe provide me with a screenshots of your custom fields, or confirm which field this ID should be?

Thanks,

Steve

Hi Stephen,

thank you for checking this out.

My script is looking for an issue of type "Managed Release"

clauseBuilder.issueType("10402");

which carries a custom field called managed release version (11801)

The scripted field 12601 is essentially a script that displays the custom field value in all issue that carry a fixversion that corresponds to the fixversion of the Managed Release issue type.

best regards

Stefan

Hi Stefan,

Try return a string instead, so in your return line 

    return result.getIssues().get(0).getCustomFieldValue(managedRelease)?.toString()

Let us know if this fix the issue.

Hi Thanos,

I have stumbled on similar bug and result.toString() solved problem.

Thanks, Jozef

Hey Jozef, thanks for letting us know :)

cheers, Thanos

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

733 views 0 3
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you