getReference Function use
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2012 04:06 AM
can anybody explain me how getReference function works in service now ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2012 04:42 AM
this is used on client side script, for example, in order to get a value from the record in a reference field, you would need to var cmdb = g_form.getReference(cmdb), cmdb.name....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2012 04:54 AM
Hi Ravi,
getReference gets the record used in another reference field. For example you have the Caller ID (reference to the sys_user table) and with getReference, you will retrieve the User record and save this as a gliderecord into a variable. The main reason to use this function is to get more information from the referenced record.
Since this is used client side, it IS a call to the server which may impact performance if used too heavily.
Example:
var gr = g_form.getReference('caller_id');
alert('Caller Email is: ' + gr.email);
Since this is a server call, as already said above, I would recommend using the callback feature (new in Aspen):
var caller = g_form.getReference('caller_id', doAlert); // doAlert is our callback function
function doAlert(caller) { //reference is passed into callback as first arguments
alert('Caller Email is: ' + caller.email);
}
With the Callback, you have no real performance impact as the UI doesnt wait for the answer to be returned and so block the User from working further.
WIKI Reference:
http://wiki.service-now.com/index.php?title=GlideForm_%28g_form%29#getReference
Cheers,
OD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2012 11:47 PM
thanks every one for the reply