Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Use of getUniqueValue() function with Glide Record object

dipesh1
Kilo Contributor

Usually getUniqueValue is used with g_from but....

If i use   getUniqueValue()   function with Glide Record object like below(assuming the table involved is Users table and the query is for a particular record on some condition)

var x = gr.getUniqueValue();

What value will I get in the variable x?

Ideally it should be the sys_id of that records but when i am updating   a different table with the value of x , I am getting the "display value" corresponding to the sys_id instead of just the sys_id....there is no additional logic written to do the conversion...

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Dipesh,



getUniqueValue will return the sys_id. Can you paste your script and steps to reproduce the issue you are facing.


Mike Allen
Mega Sage

If you are updating a different table and the field on that table is a reference back to the user table, it will show the display value.   getUniqueValue should deliver the sys_id of the record.



There is also the gel syntax:



var sysid_gel = gel('sys_uniqueValue');


var sysid = sysid_gel.value;


Anurag Tripathi
Mega Patron
Mega Patron

Hi Dipesh,



getUniqueValue   when used with g_form on a client side gives you the sys_id of the record.



If you tell what you exactly are trying to do then we might help you to achieve it.




-Anurag

Venkatesh5
Tera Contributor

Hi Dipesh,



The field which you are referring on the other table might be a reference field of same table from your getting the sys_id.



If this not the case, do let me know from which table you are retrieving the sys_id and to which table it setting as display field value.



Thanks,


Venkatesham P