Can you dot walk in server side script in Service Portal

Thomas Miles
Tera Contributor

if i wanted to get the phone number of the caller in a query to the incident table could i dot walk 

var gr = new GlideRecord(incident);

gr.addQuery('active', true);

gr.query();

while(gr.next()){

data.caller = gr.getDisplayValue('caller.phone');

 

is this possible , i want to display the callers phone number in the widget next to their name .

 

1 ACCEPTED SOLUTION

chrisperry
Giga Sage

Hi there,

Yes it is possible to dot-walk in any server script across the platform, including in service portal widgets. To get the data.caller object property populated properly, I would re-write your script as below:

var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.query();
while(gr.next()) {
data.caller = gr.caller_id.phone.toString();
}

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi

the code line

gr.getDisplayValue('caller.phone');

is not possible at all in ServiceNow and also makes no sense. Instead write

data.caller = gr.caller.phone.toString();

Maik

chrisperry
Giga Sage

Hi there,

Yes it is possible to dot-walk in any server script across the platform, including in service portal widgets. To get the data.caller object property populated properly, I would re-write your script as below:

var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.query();
while(gr.next()) {
data.caller = gr.caller_id.phone.toString();
}

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry