Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

User should not be able to select same user two times in Multi-row variable set.

Brijmohan
Tera Contributor

I am stuck on one requirement. There is one Multi-row variable set in catalog item where requester can add up to 100 users but should not be able to add the same User twice".

How I can restrict this? Please suggest.

Thanks in advance!

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello , 

For avoiding duplicate entries you can create an on submit client script inside MVRS 

PLease use the below script this will work for sure

function onSubmit() {
    var value = parent.g_form.getValue("<mrvs name>"); // change mrvs name
    var arr = JSON.parse(value);

    if (searchExisting(g_form.getValue("<column name to check>"), arr)) { // change column name
       alert('There are duplicates please remove those before submitting');
       return false;
    }
}

function searchExisting(keyColumn, newArray) {
    for (var i = 0; i < newArray.length; i++) {
        if (newArray[i].<column name to check> == keyColumn) {  // change column name
            return true;
        }
    }
    return false;
}

Please accept the solution if it helped you and close the thread. This might help others too with same query

Thanks

View solution in original post

9 REPLIES 9

Hi Mohit,

 

Though type is selected as ALL, the code isn't working in Service Portal & we have the error  "There is a JavaScript error in your browser console". Can you please suggest on this ?

Community Alums
Not applicable

What is the resolution for this ? Can you guys let me know. I am facing the same issue

 

Allen Andreas
Tera Patron

Duplicate post, please delete one of these: https://community.servicenow.com/community?id=community_question&sys_id=b7f30d19dbe09590457ae6be1396...


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Done, thanks for letting me know.

Community Alums
Not applicable

@Allen Andreas Your provided link is not available , could you please send that here again which might be helpful for us.