- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 12:22 PM
Below is the code that I am trying to run in background script to get URL of the knowledge articles, once we get the URL I want to append it with 'href=" ' tag along with it's header, but it is giving me error when I put that lien in the code, other runs fine if I remove line 20. not sure what is missing.
Code :
var gr = new GlideRecord("u_kb_template_teutr_production_installation_guide");
gr.addQuery("number", "KB0051586");
gr.query();
if (gr.next()) {
var str = gr.u_introduction;
var newstr ='';
gs.print("Intro value" + str);
var regex = /(\[(?:\[??[^\[]*?\]\]))/g;
var arr = str.match(regex);
for(var i = 0; i < arr.length; i ++) {
var title = arr[i].split("|")[0].replace("[[", "").trim();
var solutionId = arr[i].split("|")[1].replace("]]", "").trim();
gs.print("\n\nTitle: " + title + "\nSolution ID: " + solutionId);
var gr1 = new GlideRecord("kb_knowledge");
gr1.addQuery("u_ra_id", solutionId);
gr1.query().id
if (gr1.next()) {
gs.print("article number" + gr1.number);
var url = gs.getProperty('glide.servlet.uri') + gr1.getLink();
gs.print("URL" + url);
//var newurl = 'href=\"' + url + '\" ' + 'target=\"_blank\"';
var newurl ='href="'+url+'" target="_blank"';
gs.print("newurl" + newurl );
var html = newurl+ '<' + title.toString() + '</a>';
gs.print("complete HTML" + html);
}
newstr=str.replace(arr[i], html);
gs.print("new string " + newstr);
gr.update();
}
}
Error : Javascript compiler exception: missing ; before statement (null.null.script; line 20) in:
I want to form HTML text like below:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 12:29 PM
Hi,
Try this
var newurl = 'href=\"' + url + '\" ' + 'target=\"_blank\"';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 12:29 PM
Hi,
Try this
var newurl = 'href=\"' + url + '\" ' + 'target=\"_blank\"';

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 12:30 PM
Update as below:
var newurl ='href="'+url+'" target="_blank"'; ==== this is line 20
Regards,
Vamsi S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 01:23 PM