Links available on the Knowledge article should be displayed on a new widget on the portal
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2024 07:02 AM
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2024 11:31 PM
Hi @Sagar Rd ,
In the HTML template section of your widget, you can define how you want the links to be displayed. Here’s an example of how to do it:
<div>
<h3>Reference Links</h3>
<ul>
<li ng-repeat="link in data.links">
<a href="{{link.url}}" target="_blank">{{link.label}}</a>
</li>
</ul>
</div>
In the client script section of your widget, you need to fetch the reference links from the Knowledge Article and bind them to the widget's data. Here’s an example client script:
(function() {
// Function to fetch reference links for a given knowledge article
function fetchReferenceLinks(articleSysId) {
// Initialize an empty array to store the links
var links = [];
// Define a GlideRecord to query the Knowledge Article table
var gr = new GlideRecord('kb_knowledge');
if (gr.get(articleSysId)) {
// Assuming the reference links are stored in a field named 'u_reference_links' in JSON format
// Example JSON: '[{"label": "Google", "url": "https://www.google.com"}, {"label": "ServiceNow", "url": "https://www.servicenow.com"}]'
var referenceLinks = gr.getValue('u_reference_links');
if (referenceLinks) {
links = JSON.parse(referenceLinks);
}
}
return links;
}
// Replace 'YOUR_KNOWLEDGE_ARTICLE_SYS_ID' with the actual Sys ID of the knowledge article
var articleSysId = 'YOUR_KNOWLEDGE_ARTICLE_SYS_ID';
// Fetch the reference links for the specified knowledge article
$scope.data.links = fetchReferenceLinks(articleSysId);
})();
Thanks,
Ratnakar