Dotwalked field value is not being accessed

AM24
Giga Guru

Hello,

I am attempting to dotwalk and get a value from another table in a client script. I am doing something like:

var startDate = g_form.getValue('table.approved_start_date');

alert(startDate);

My alert shows up as blank every time. I have tried it out on other fields on the table, but they have not shown up either. I did the same thing using another table that I reference, and that works perfectly. I was wondering what could be the problem since the reference field name and the desired field name are correct.

1 ACCEPTED SOLUTION

Filipe Cruz
Kilo Sage
Kilo Sage

Hi AM,

You need to use the getReference method:

https://developer.servicenow.com/dev.do#!/reference/api/quebec/client/c_GlideFormAPI#r_GlideForm-Get...

You should use it with a callback function like this, inside your client script:

g_form.getReference("table", callbackFuntion);

function callbackFunction(obj){
   var date = obj.getValue("approved_start_date");
   alert(date);
}

As stated in the website I provided:

If a callback function is present, this routine runs asynchronously. The browser (and script) processing continues normally until the server returns the reference value, at which time, the callback function is invoked. If a callback function is not present, this routine runs synchronously and processing halts (causing the browser to appear to hang) while waiting on a server response.


This should work for you, but don't forget the callback function!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz



View solution in original post

5 REPLIES 5

Hi Filipe,

There's another point about using GlideRecord in client-side. Client-side GlideRecord is not supported in scoped applications. The current recommendation nowadays is to create custom applications in scoped applications when possible.

The client-side GlideRecord API is not supported in scoped applications. Instead, create a script include and use the GlideAjax API, or use the REST APIs.

Another difference is on ACL. Client GlideRecord would require user to have privilege on table being accessed.

In addition, the client-side GlideRecord API applies ACLs based on the credentials of the user executing the script. To execute the code on the server without ACLs, use the GlideAJAX API.

It is easier to teach and also maintain codes if they all follow the same pattern. When using several patterns based on conditions, more have to be taught.

https://developer.servicenow.com/dev.do#!/reference/api/sandiego/client/c_GlideRecordClientSideAPI?n...