Regarding drop down with none option

joshishree
Kilo Contributor

The exi cluster field is drop down with none .

and its a mandatory field

if no value is given its still allowing to save the ritm form

is there any value for none

find_real_file.png

I dont want to give a default value to this field

1 ACCEPTED SOLUTION

Hi Bhagyashree,



So it means somebody has added None as choice and not used drop down with none functionality at dictionary level. Can you configure the dictionary for that field and check choices for that



If somebody has added --None-- as choice then 2 options


1) remove --None-- as choice and make it dropdown with none


2) update your script to compare with --None-- whenever you want to compare with emptiness



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Bhagyashree,



If it is drop down with none and is mandatory field then you need to select value other than None.


For None the value is '' i.e. empty string


Can you check the dictionary again for this field?



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

.


I gave the condition if exi_cluster is empty string then give alert("fill exi cluster").


Not working




--None--exi


when none is selected i have given an alert its showing the above line


Hi Bhagyashreee,



So when you have used below line and if getting alert when empty then your code is working fine right? It is showing alert to fill it if it is empty


if(g_form.getValue('exi_cluster') == ''){


alert('fill exi cluster');


}



Can you share your script?


What is the exact confusion you are having?



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

var exsi_cluster = g_form.getValue('exsi_cluster');


  if(exsi_cluster == '')


  {


  alert("fill exi");


  }


no alert is coming for both cases(none or having some value)




i tried to give alert before if



var exsi_cluster = g_form.getValue('exsi_cluster');


alert(exsi_cluster );


  if(exsi_cluster == '')


  {


  alert("fill exi");


  }




so in above code if none option is present i am getting an alert like


find_real_file.png





if some value is present in exi cluster   its giving proper value




My issue is that in above 1st code why it is not going inside the if loop if none option is present