Notifications

49 views

Description

On the Service Portal, when submitting a catalog item, the form freezes at 'submitting...' and the record is not created.  Additionally, there is a console error that reads '500 (Internal Server Error)'.  Also, expanding the returned JSON objecting in the console reveals the following information under the 'data' key:

 

message: "java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String

Cause

The cause maybe a Catalog Client Script setting a JavaScript Number type in a string variable field.  One example where you this could happen is performing math operations which return a JavaScript number type, not a JavaScript string type. 

 

var num = 5 * 9; // returns a variable type Number

 

g_form.setValue('string_type_variable', num); // erroneously setting a string field type with a Number type variable

Resolution

Use toString() method to convert the variable to a String type before using the same variable to populate a String field, like so:

 

var num = 5 * 9;

var str = num.toString();

g_form.setValue('string_type_variable', str);

 

 

Article Information

Last Updated:2019-10-08 03:03:59
Published:2019-10-08