Getting value of the field instead of sys_id

ravali6
Giga Contributor

I have a script where I do a GlideRecord query to the request table. Once I get the records, I am getting to the value of the opned by field. But since opened by is a reference field, it is returning sys_id. How can I get the displayed value ?

Below is the script :

var gr = new GlideRecord("sc_req_item");
gr.addQuery("u_requested_for", g_form.getValue("emp_name"));
gr.addQuery("stage",'!', "waiting_for_approval");
gr.query();

if(gr.next())
{
alert("A request has already been submitted by " + gr.opened_by); // this is returming sys_id, I need the value

}


Please let me know if anyone has any suggestions.

22 REPLIES 22

Aaron40
Kilo Guru

alert("A request has already been submitted by " + gr.opened_by.getDisplayValue());

Can you try that?


ravali6
Giga Contributor

Hi Aaaron,

Thanks for the reply, yes I tried with the getDisplayValue(), seems to be not working.


Hi Ravali,

Sorry you're still have trouble getting this to work. I just went to one of the demo labs and ran this as a background script.



var gr = new GlideRecord("sc_req_item");
gr.query();

if(gr.next())
{
gs.log(gr.opened_by.getDisplayValue());
}


This is getting the display name of the user back. Are you trying to use this in a business rule or a client script?


ravali6
Giga Contributor

I am trying to do this in the client script.. I know I have had this working previously in the past, not sure why it is not working..