How to get Values from Custom with Label Variable ? How to set limit of values and restrict submit

S Deva
Tera Contributor

There is a variable Custom with Lable for selecting multiple change requests. It should have at least 3 values before the submit form. 

 

I have added script : 

 

var Changes = g_form.getvalue("field_name").toString().split(',');

var changes_length = Changes.length;

if(changes_length>=3){

return true;

}

return false;

 

But this is always return false . How to achieve this can anyone please help ?

11 REPLIES 11

AnubhavRitolia
Mega Sage
Mega Sage

Hi @S Deva 

 

Is your variable type is List collector?

 

Can you show how your variable and its values look?

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Screenshot 2022-12-01 200158.jpg

S Deva
Tera Contributor

 

This is the variable belongs to Propose new standard change Record Producer 

We can select multiple changes in this field. and here the requirement is at least it should have 3 values if not restrict the form to submit. Can you please guide me how can we achieve ?

 

Hello @S Deva ,

That field is rendering through macro .it not a variable which is created on the form .its a macro as you can see in your custom with label field there is a macro attached so the values are coming from there .

In this case you might have to handle the scenario in macro code .Because you cant access the values selected in macro in a client script 

Hope this helps 

Mark my answer correct if this helps you 

Thanks