ClientScript - onSubmit() - How to get value of a reference field by dot walking?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 02:06 AM
I am creating onSubmit client script and need to access of the reference field's table field value...I tried it by dotwalking but it didnt let me...I would liek to compare two values like this on my form (both reference fields)...anyone can help me?
I tried this:
function onSubmit() {
if(g_form.getValue('u_business.u_active') == false){
alert('Record submission aborted.');
return false;
}
with no luck...
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 02:15 AM
Hello,
You cannot directly use a dot walking in Client Script, instead do a callback function using the API - getReference. I will try giving you the code in a while.
Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 02:45 AM
Thanks, I am getting so stuck because I need to compare two reference field values...and if they are on form equal then I need to abort submition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 02:49 AM
If I consider the above script, this will work. I used company field as reference field here.
function onSubmit(){
var companyValue = g_form.getReference('company', callbackfn);
function callbackfn(companyValue) {
if (companyValue.active == 'false') {
alert('Record submission aborted.');
}}
return false;
}
If your case is to validate two reference fields and if the the reference field table's list of records are very big in count, I suggest you go for Script Include and GlideAjax functionality.
If you think the load to the system is minimal then use the same lines of code for the second call back function.
Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 02:59 AM
Thanks, however this wont update the form at all, meaning even if the value is "true"
companyValue.active == 'false'