calling scriptinclude from link in catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I want to place a link in a catalog item (created via Record Producer) that calls a Script Include. Is it possible to generate a link using a Script Include? Also, is there a way to call a script that performs server-side processing without calling a Script Include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @t-takumi
Try this:
- Create a variable
- Open your Record Producer.
- Create a new Variable.
- Set the Type to Rich Text Label or Custom (using a UI Macro/Widget).
- Give it a name (e.g., dynamic_link_placeholder)
- Create the Client-Callable Script Include
- Navigate to System Definition > Script Includes >Click New.
- Client callable : checked
var DynamicLinkGenerator = Class.create();
DynamicLinkGenerator.prototype = Object.extendsObject(AbstractAjaxProcessor, {
generateCatalogLink: function() {
var recordSysId = this.getParameter('sysparm_record_id');
var baseUrl = "/sp?id=sc_cat_item&sys_id="; // Example portal route
var finalUrl = baseUrl + recordSysId;
return '<a href="' + finalUrl + '" target="_blank" style="color: blue; text-decoration: underline;">Click Here to View Details</a>';
},
type: 'DynamicLinkGenerator'
});
- Create the Catalog Client Script
- On your Record Producer, go to the Catalog Client Scripts related list.> Click New.
- Set the Type to onLoad (or onChange depending on your requirements).
- Set the UI Type to All
function onLoad() {
var ga = new GlideAjax('DynamicLinkGenerator');
ga.addParam('sysparm_name', 'generateCatalogLink');
ga.addParam('sysparm_record_id', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
if (response) {
g_form.setValue('dynamic_link_placeholder', response);
}
});
}
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Thank you.
When I created it the same way, a JavaScript error appeared in the browser console.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Hi @t-takumi
Share the error please , error screen shot would be fine.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
you can show link in catalog form using different variable types (Custom or HTML)
But what should happen on click of that?
what's your exact business requirement?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader