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 03:04 AM
That's right, my bad. You can edit and modify the rest of your code 🙂 I have seen Ankur has given good code for this.
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:17 AM
Tr using getReference.
Here is the article that might help - https://community.servicenow.com/community?id=community_question&sys_id=9a0dc769db9cdbc01dcaf3231f96...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 02:47 AM
Hi,
You cannot dot walk in client script on reference field/variable
try to use getReference with callback
function onSubmit(){
var business = g_form.getReference('u_business', getValue);
}
function getValue(business){
if(business.u_active.toString() == 'false')
return false;
else
return true;
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader