Question: In a client side script I have checks fo...
# suitescript
m
Question: In a client side script I have checks for the saveRecord function doing explicit validation, but how do I see if the required fields that are checked in the custom form screens field are filled in also? The current behavior is that an alert is fired for the "required" fields then it checks my explicit checks in my saveRecord function. Is there a way to check if the form validation is valid in my saveRecord function?
a
You can declare a global variable outside your entry points and populate it or not if your validations passed, then check it on saveRecord.
m
I want to see if the built in form validation is valid before checking my custom validations. Basically I have a field that is require in the form. The normal, built-in validator will pop up an alert when I click the save button and tells me that the field is required. Basically I want to be able to read the current form state in the DOM and check if the form is valid to submit, then run my custom validation that I write in the client side script. I currently tried to recreate the onsubmit function that is used in the DOM that is assigned to save button, but the functions it calls (window.NS.form.isInited() && window.NS.form.isValid()) always return true no matter the actual validitiy of the form. And then it runs a window.save_record(true) to check if the record has already been submitted. When I try to run that function in the CS script it runs an infinite loop.
a
Any special reason you need to be able to capture exactly the same form validation NetSuite is doing?
m
I am trying to create an alert in the saveRecord function when a certain field boolean is set to true and the Save button is pressed. Which it works, but I only want it to trigger if the form is valid. I am open to any alternatives!
r
If I recall correctly, NetSuite performs the form validation before the client-side script execution. Is that not enough for your use case?
m
And that is fine. I just want to be able to run certain parts of the saveRecord CS function only if the NetSuite form validation passes. Maybe I am not understanding the proper usage of the saveRecord function.