How to setup MRVS Minimum row count?

Kritika1
Tera Contributor

From the Thread :

https://www.servicenow.com/community/developer-forum/how-to-set-minimum-row-requirement-of-mrvs/m-p/...

 

Hi All,

 

I wrote the same code, but it is not working. 

Can you pelase check the issue:

function onSubmit() {
    var bulk = g_form.getValue('is_this_a_bulk_request_for_than_5_account');
    var mrvs = g_form.getValue('user_details_bulk'); //mrvs1
    var mrvs2 = g_form.getValue('user_details_remove_bulk'); //mrvs2
    var parser = JSON.parse(mrvs);
    var parser2 = JSON.parse(mrvs2);

        if(parser.legth < 2 || parser2.length < 2)
        {
        g_form.addErrorMessage('Oops, you have submitted a bulk request for 1 user.  Please either add additional users; or if your request is for 1 user, select the option of "1 account".');
        return false;
        }
}
 
It just throws the Javascript error.
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Kritika1 

your script is wrong.

some correction here

function onSubmit() {
    var bulk = g_form.getValue('is_this_a_bulk_request_for_than_5_account');
    var mrvs = g_form.getValue('user_details_bulk'); //mrvs1
    var mrvs2 = g_form.getValue('user_details_remove_bulk'); //mrvs2
    var parser = JSON.parse(mrvs);
    var parser2 = JSON.parse(mrvs2);

    if (parser.length < 2 || parser2.length < 2) {
        g_form.addErrorMessage('Oops, you have submitted a bulk request for 1 user.  Please either add additional users; or if your request is for 1 user, select the option of "1 account".');
        return false;
    }
}

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