- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 02:40 PM
Hello I have this code that is querying a table called "hr_case". This is a Mail Script that is called on an email notification. However, it is not working. It is not properly querying. I tried "template.print(current.sys_id)" and it is properly returning the sys id, however, the query is not getting executed properly. I tried adding something like "template.print("RECORD FOUND");" inside the "if" scope to see if the record was being found but it is not. I tried passing a hard-coded sys-id for an incident and changed the queried table to 'incident' and that one DOES work. So it seems that the issue is only with the "hr_case" table. I also tried changing the "next()" and "query()" methods to "_next()" and "_query()" just in case there was a field in the table called next or query. Please let me know if you have any ideas. Thanks.
var link = '';
var rec = new GlideRecord('hr_case');
rec.addQuery('sys_id', current.sys_id);
rec.query();
if(rec.next()){
link = gs.getProperty('glide.servlet.uri') + 'nav_to.do?uri=' + rec.getLink();
}
var pos = link.indexOf('sys_id');
var ess_link = link.substring(0,pos) + 'sysparm_view=ess%26' + link.substring(pos);
template.print('<a href="' + ess_link + '">${number}</a>');
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 03:18 PM
sys_id is a property on the current object that holds the sys_id of the record. Did you try current.getLink()?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 03:18 PM
sys_id is a property on the current object that holds the sys_id of the record. Did you try current.getLink()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 03:28 PM
Ah! yes! it works now. This is what I did:
var link = gs.getProperty('glide.servlet.uri') + 'nav_to.do?uri=' + current.getLink();
var pos = link.indexOf('sys_id');
var ess_link = link.substring(0,pos) + 'sysparm_view=ess%26' + link.substring(pos);
template.print('<a href="' + ess_link + '">${number}</a>');
I'm still confused as to why GlideRecord was not working on this table, regardless of what I wanted to accomplish here in the future I could face issues with querying this table, but that is something aside from this question. Thanks Brad!