How to restrict users to select not less 2 records in list collector in serviceNow

Sowmya
Tera Contributor

The purpose of list collector is to select more than 1 records . Can we populate an alert message to select more than 1 record in list collector ServiceNow. Kindly let us know the update asap.

1 ACCEPTED SOLUTION

Amit Gujarathi
Giga Sage
Giga Sage

HI @Sowmya ,
I trust you are doing great.
You can do it using the client script on change one.

Once the value is changed into the list collector it will be passed to the backend where it will be shown as comma seperated sysIds for the reference.

var glideList = g_form.getValue('<glide list field>');

It will give output as sys_id1,sys_id2.
Then you can split it as given below :
var glideListArray = glideList.split(',');

if (glideListArray.length > 2) {

alert ('Invalid')

}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

5 REPLIES 5

Amit Gujarathi
Giga Sage
Giga Sage

HI @Sowmya ,
I trust you are doing great.
You can do it using the client script on change one.

Once the value is changed into the list collector it will be passed to the backend where it will be shown as comma seperated sysIds for the reference.

var glideList = g_form.getValue('<glide list field>');

It will give output as sys_id1,sys_id2.
Then you can split it as given below :
var glideListArray = glideList.split(',');

if (glideListArray.length > 2) {

alert ('Invalid')

}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Hi Amit,

Thanks for the solution,

I tried the onchange client script which you suggested. But not working Basically it should throw an alert message if i select only one record in list collector.

function onChange(control, oldValue, newValue, isLoading) {
var glideList = g_form.getValue('user_list');


var glideListArray = glideList.split(',');

if (glideListArray.length > 2) {

alert ('Invalid');

}
}

Change this line as follows pls

 

 

if (glideListArray.length < 2) 

 

Sowmya
Tera Contributor

Thank you its working