getUniqueValue() returning undefined in email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 09:19 AM
I'm having issues when using getUniqueValue(). I'm attempting to retrieve the sys_id as as string to build a link to a particular demand. Code below is what I'm using and calling the variable 'dmnNameLink' immediately after.
var dmnNameLink = '<a href="https://' + gs.getProperty('instance_name') + '.service-now.com/nav_to.do?uri=dmn_demand.do?sys_id=' + dmnGr.getUniqueValue() + '">' + dmnGr.short_description + '</a>';
The issue is that when I view the output the value of dmnGr.getUniqueValue() I keep getting 'undefined'. Any ideas why? This very same method is working in an almost identical script for project records, the only difference being that there the variable names are different. Here's the working example of that:
var projNameLink = '<a href="https://' + gs.getProperty('instance_name') + '.service-now.com/nav_to.do?uri=pm_project.do?sys_id=' + projGr.getUniqueValue() + '">' + projGr.short_description + '</a>';
^This one works great... Not sure what the issue is.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 05:52 PM - edited 05-25-2023 05:53 PM
instead you can also try using .sys_id
EX:
var dmnNameLink = '<a href="https://' + gs.getProperty('instance_name') + '.service-now.com/nav_to.do?uri=dmn_demand.do?sys_id=' + dmnGr.sys_id + '">' + dmnGr.short_description + '</a>';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 08:13 AM
I tried this as well and it also comes back undefined. I also read here that using getUniqueValue() is preferred over .sys_id as it guarantees a string value where .sys_id might return either a string or type object. I'm not completely sure on that myself however.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 10:41 PM
Hi @Raymond Norvell ,
There is nothing wrong with the link code you are using. I recreated it on my PDI and it is working.
Please check how you are getting the demand record set in dmnGr. There might be some problem in that code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 08:15 AM
Hi Manmohan, thanks for the response. This is how I'm getting the demand record (note that this is being run when a demand task is assigned):
var dmnGr = new GlideRecord('dmn_demand');
dmnGr.get(current.sub_tree_root);