The CreatorCon Call for Content is officially open! Get started here.

Populated MRVS rows with empty fields are saved as null

smicloud
Tera Guru

I am working with a copy function in a record producer. If I select a case in a "Copy MRVS data from case" field then the MRVS in present order form is populated with the MRVS data from the selected case. 

 

If the data being copied contains fields with no values (e.g. string fields), the data is saved as null in sc_multi_row_question_answer when submitting the form with the copied data. 

 

We are using glideajax to get the data in a catalog client script and populates the MRVS from there. Only the fields with values are retrieved (the other ones were saved but is not retrieved when asking for all MRVS for that case referring to case.variables.variable_set, seems like ServiceNow is deciding not to send field data with empty values). When saving the new case with copied MRVS data, all fields are saved, even the empty ones but those get null as value instead of nothing/empty string. 

 

If we are copying the copied case MRVS data, the MRVS fields that are empty are populated with null. 

 

When debugging, I created a before BR on sc_multi_row_question_answer and printed the values that are saved as null. They are not null when I try to print them. But the BR is having a condition that value should be null and it is actually triggered. Something happens when the data is being saved but only for data that was copied. I was hoping I could change null to empty string in the BR but it doesn't work. 

 

Can anyone elaborate about what the problem can be and a potential fix? My workaround is to loop through all data retrieved in the catalog client script when copying the data and changing null to empty string. The data is still saved as null and this is what I would like to avoid, the fields should be empty not null. But at least null is not presented in the MRVS table in the record producer. 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@smicloud 

are you using GlideAjax to bring the old MRVS data for the copy?

In the script include check if the variable has value or not, if not then set it with empty string to avoid null

share the complete scripts and screenshots here

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

As mentioned I am using GlideAjax to return the value to the client.

 

I ended up dynamically fetching the definition of the variable set and looped through all variables in the variable set checking if they are part of the data being sent back to the catalog client script. If the variable is not part of the data being returned I am setting the value to empty string.