List Collector

priyanka1028
Tera Contributor

Hello,

 

I want to set limit of choices 5 on list collector. 
How can we implement this any idea?

1 ACCEPTED SOLUTION

Samaksh Wani
Giga Sage
Giga Sage

Hello @priyanka1028 

 

You need to write a onSubmit() Catalog Client Script 

Applies to Catalog Item

Applies on Catalog Item view -  True

UI Type = ALL

 

 

function onSubmit()

var values = g_form.getValue('variableName').toString().split(',');

if(values.length > 5){

alert('Please select only 5 choices');

return false;

}

}

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

 

 

View solution in original post

11 REPLIES 11

Community Alums
Not applicable

Hi @priyanka1028 ,

write onSubmit catalog client script

Applies to Catalog Item

Applies on Catalog Item view -  True

UI Type = ALL

Note: give your list collector variable name below

function onSubmit()
{
var values = g_form.getValue('variableName').toString().split(',');

if(values.length > 3){

alert('Please select only 3 choices');

return false;

}

}

Also, refer to the link too for another way : https://servicenowguru.com/scripting/client-scripts-scripting/limiting-selections-list-collector/

 

Samaksh Wani
Giga Sage
Giga Sage

Hello @priyanka1028 

 

You need to write a onSubmit() Catalog Client Script 

Applies to Catalog Item

Applies on Catalog Item view -  True

UI Type = ALL

 

 

function onSubmit()

var values = g_form.getValue('variableName').toString().split(',');

if(values.length > 5){

alert('Please select only 5 choices');

return false;

}

}

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

 

 

Actually I have tried this but I want solution like if we add more than 5 choices that time it wont be able to add those choices.

In that Case, Use onChange Catalog Client Script.

 

@priyanka1028