GlideSubstituteURL().generateURL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 03:25 AM
Hi All,
Can anyone explain me the usage of 'GlideSubstituteURL().generateURL' in the script below or in general.
Script:
template.print("<br />");
var gr = new GlideRecord("kb_knowledge");
gr.addQuery('source', current.sys_id);
gr.query();
while (gr.next()) {
var link = new GlideSubstituteURL().generateURL(gr, '');
var title = gr.number;
if (gr.short_description != '') {
title+= " - " + gr.short_description;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 06:46 AM
It appear to be doing anything in the script you pasted. The link variable doesn't appear to be referenced after it's declared.
In general, GlideSubstituteURL().generateURL() will build out a URL for a given GlideRecord.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2017 10:52 AM
Thank you Justin.
Here is the complete script.
template.print("<br />");
var gr = new GlideRecord("kb_knowledge");
gr.addQuery('Active', true);
gr.addQuery('valid_to', '<', gs.daysAgo(30));
gr.query();
while (gr.next()) {
var link = new GlideSubstituteURL().generateURL(gr, '');
var title = gr.number;
if (gr.short_description != '') {
title+= " - " + gr.short_description;
}
var anchor = "<a href='" + link +"'>" + title + "</a>";
template.print(anchor + "<br />");
Does template.print - Prints the output under system log?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2017 11:18 AM
Hi Shalini,
No it renders the content in the email body the mail script is called in.
In your case it will generate the link to GlideRecord'ed record with text as short description.
Use gs.log() above/instead of template.print() to display under system log.
Thanks,
Tanaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2017 05:34 AM
Thank you Tanaji,
I did not understand what you meant by 'No it renders the content in the email body the mail script is called in'.
Could you explain in detail.
What does template.print in general do?
And what it is doing in this case.
The code here is for Notification Email Scripts.
I know the tag "<br> ..."<br /> is used for line breaking.