onsubmit validation : syntaxerror: unexpected end of json input servicenow

Ankita9793
Tera Contributor

Hi All,

 

For below OnSubmit script, I am getting syntaxerror: unexpected end of json input servicenow. Can someone please suggest what can be rectified? 

 

function onSubmit() {

    var type = g_form.getValue('request_type');

    if (type != 'Delete') {
 
        var mrvsData = g_form.getValue('multiple_staff_id');

        var parsedData = JSON.parse(mrvsData);
        var rowCount = parsedData.length;
        if (rowCount > 20) {

            alert('Please do not add more than 20 records in the excel sheet/ attachment.');
            return false;
        }  

        return true;
    }

    if (type == 'Delete') {
 
        var mrvsData2 = g_form.getValue('delete_multiple_users');
        var parsedData2 = JSON.parse(mrvsData2);

        if (parsedData2.length > 20) {

            alert('Please do not add more than 20 records in the excel sheet/ attachment');
            return false;
        }

        return true;

    }
}
1 ACCEPTED SOLUTION

J Siva
Tera Sage

Hi @Ankita9793 
Make sure that your MRVS is not empty while submitting the form.
Regards,
Siva

View solution in original post

1 REPLY 1

J Siva
Tera Sage

Hi @Ankita9793 
Make sure that your MRVS is not empty while submitting the form.
Regards,
Siva