- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2018 09:42 AM
I have a scenario where i need to get the values from a reference field popup in clientscript during onsubmit of form.
below is my code
the issue is before the ValidateCus function completed its execution, the if condition of if(validationFailed == true) is executed and as the initial value of variable 'validationFailed' is false the form is submitted.
var x = g_form.getReference('inv_customer', validateCus);
var validationFailed = false;
function validateCus(customerInfo)
{
if(g_form.getValue('fm_cst') == customerInfo.cst)
{
validationFailed = true;
}
}
if(validationFailed == true)
{
return false;
}
else
{
return true;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2018 10:15 AM
From wiki
getReference(String fieldName, Function callBack)
Returns the GlideRecord for a specified field.
If a callback function is present, this routine runs asynchronously, and browser (and script) processing will continue normally until the server returns the reference value, at which time the callback function will be invoked. If a callback function is not present, this routine runs synchronously and processing will halt (causing the browser to appear to hang) while waiting on a server response.
In your case since this is asynchronous call onSubmit script will not work; Try to move your validation to onChange
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2018 10:38 AM
Yes, I do not see any better solution;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2024 02:45 AM
Thank you for explaining this in laymen.