How To Dot Walk Multiple Tables

thisisauniqueus
Giga Expert

Hi

I am accessing multiple tables by dot walking, but getting empty value when i dot walk the second time. For example i have written a Bussiness

Rule on sys_import_set_run in that i am accessing the sys_import_set table like

current.set.getRefRecord().getValue('state');

but when i try to access the sys_data_source table like

current.set.getRefRecord().getValue('data_source').getRefRecord().getValue('u_email_address');

i get the empty value

So the question is can i dot walk and get the values of multiple tables? If yes please guide me how to correctly do it..

Regards

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi John,



Dot-walking is really quite simple. You do not need to call methods, just use a reference field to go from one place to another.



current.set.state; // get the state of the import set



and



current.set.data_source.u_email.address;



are two examples of what you tried to do above.



Be aware, if one of the intermediate values are null, (for example data_source, in the second example) you will get a null pointer exception error thrown in the log. Always check your variables to ensure they contain a valid value before dot walking.



// Better


var state = '';


if (current.set)
        state = current.set.state;



Good luck!


View solution in original post

5 REPLIES 5

Harsh Vardhan
Giga Patron

Hi John,



Please refer the link below.



Dot-Walking - ServiceNow Wiki



Regards,


Harshvardhan


Thanks harsh for your time the article was helpful



Regards


Chuck Tomasi
Tera Patron

Hi John,



Dot-walking is really quite simple. You do not need to call methods, just use a reference field to go from one place to another.



current.set.state; // get the state of the import set



and



current.set.data_source.u_email.address;



are two examples of what you tried to do above.



Be aware, if one of the intermediate values are null, (for example data_source, in the second example) you will get a null pointer exception error thrown in the log. Always check your variables to ensure they contain a valid value before dot walking.



// Better


var state = '';


if (current.set)
        state = current.set.state;



Good luck!


It took me some time to understand , thanks Chuck for your suggestion ...



Regards