When submitting a record producer from Service Portal, if any of the fields is set to 'null' object the catalog item is not submitted and stuck on the "Submitting..." message.

And the following error message is displayed in the browser console:

VM539:1 POST https://<instance_name>.service-now.com/api/sn_sc/v1/servicecatalog/items/<record_producer_sys_id>/submit_producer 500 (Internal Server Error)
REST Failure
message: java.lang.NullPointerException // this will be in a JSON object with more info relating to the error.

- the record producer works in the backend service catalog.
- this issue is reproducible from Madrid Patch 6 onwards.

Steps to Reproduce

Pre requisite:

Testing this requires some setup, I have captured all of them in the attached update set: sys_remote_update_set_31542f28d02840104e8203a5a43fd37c.xml

It creates the following:
- Adds a field to "incident" table: u_caller_email | String
- Modifies OOB Record Producer "Create Incident" [sys_id: 3f1dd0320a0a0b99000a53f7604a2ef9]
-- Adds variable: Caller | caller_id | Reference [sys_user] | Map to field = true
-- Adds variable: Caller Email | u_caller_email | Single Line Text | Map to field = true
- Script Include: GetUserDetails | function getUserEmail()

var GetUserDetails = Class.create();
GetUserDetails.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

getEmail: function() {
var user = GlideRecord('sys_user');
return user.getValue('email');

type: 'GetUserDetails'

- Catalog Client Script (Item: Access): [onChange: caller_id] Populate user email

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {

//Type appropriate comment here, and begin script below
var ga = new GlideAjax('GetUserDetails');
ga.addParam('sysparm_name', 'getEmail');
ga.addParam('sysparm_user_sys_id', g_form.getValue('caller_id'));

function populateUserEmail(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('u_caller_email', answer);

Steps to Reproduce

1. Go to sys_user record for Abel Tuter
--- /sys_user.do?sys_id=62826bf03710200044e0bfc8bcbe5df1
2. Remove the "Email" value for this user and save.
3. Go to the service portal and open the record producer
--- /sp?id=sc_cat_item&sys_id=3f1dd0320a0a0b99000a53f7604a2ef9
4. For Caller, select Abel Tuter, the Caller Email field will remain blank.
5. Fill the rest of the mandatory fields
6. Submit.


The issue here is that the user we are trying to fetch the email for doesn't have an email, so the following code:

return user.getValue('email') --> returns obj when null and string when there is a value.

There are two ways to fix this.

1. Perform a check, in the client script, before setting the value:

if (answer) { // or whatever contains the value you are trying to set
g_form.setValue('u_caller_email', answer);
} else {
// setting to an empty string and not null object
g_form.setValue('u_caller_email', '');


2. Change the data type being returned from the script include called by the GlideAjax:

Instead of using getValue() function you can directly access the field from the GlideRecord object,

return user.email --> returns an empty string when null and string when there is a value

Related Problem: PRB1368187

Seen In

Madrid Patch 6

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2020-11-23 04:59:30