The CreatorCon Call for Content is officially open! Get started here.

embedded list field validation on submission of form

siramdasu
Mega Contributor

Hi I have two embedded lists in a form, a field name called uni_number in both the embedded lists, on submission of form or on saving of form, it should throw a notification or error message that uni_number should be 12 digits.... this i have done on the individual tables of embedded lists but it didn't work when user enters data in embedded list....

7 REPLIES 7

yeah i have written business rule



var pur= new GlideRecord("x_rtp_sv_pdi_pack_size_purchase");


pur.addQuery("upc_code", current.upc_code);


pur.query();


if(pur.next()){


var upc=pur.upc_code;


if(upc.length!=12){


gs.addErrorMessage("UPC length should be 12 digits");


}


}


var sal= new GlideRecord('x_rtp_sv_pdi_pack_size_sales');


sal.addQuery('upc_code', current.upc_code);


sal.query();


if(sal.next()){


var upc1=sal.upc_code;


if(upc1.length!=12){


gs.addErrorMessage("UPC length should be 12 digits");


}


}



but its not validating... even though I given 12 digits getting error message as UPC length should be 12 digits


how about if you set the field length to only enter 12 char from dictionary level then in that case you don't need to write any script. max length 12



now coming to your script would you try to set some log in your script and check what are you getting when using ups.length.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Hemanth,



Can you please give more details on how you have implemented your solution i.e " this i have done on the individual tables of embedded lists "



FYI: In case you are validating via client script, this won't be triggered on list view unless it is a OnCellEdit CS.


Please let me know if you have any questions.



P.S: The other solution will be to write a BEFORE business rule on the table and abort the form submission per your logic.