Mail script not working while trying to fetch GlideRecord from a non-task table using documet_id of approval record

rambo1
Tera Guru

var gr = new GlideRecord('u_capex_requests');

gr.get('sys_id', current.document_id);

template.print(gr.u_requestor_name);

tried this in mail script to get requestor name in email body, but it is not happening. Please suggest some alternatives to get requestor name in email body.

16 REPLIES 16

Dubz
Mega Sage

Hi Rohith,



Try the below:



var gr = new GlideRecord('u_capex_requests');


gr.addQuery('sys_id', current.document_id);


gr.Query();



while(gr.next()){


template.print(gr.u_requestor_name);.


}


Tried, not working


Chuck Tomasi
Tera Patron

Have you tried "simulating" it in scripts background?



Faster Server Side Script Development and Test


Do not understand how can this be tested in background. The mail script takes relevant approval's document_id which is sys_id of the original ticket.



If I put sys_id in place of current.document_id inbackground script it certainly works. I have also tested that the document_id is puts out correct value.



The issue I found is that Glide script not working in that email script. If I just query a table and try to print getRowCount(),   it prints 0.



Is there any method to find out why Glide script not working in mail script ? I have tried Debug already could not understand anything.



I tried the same code in my personal instance and it works pefectly to fetch the details of original ticket using approval's document_id.