Add header link to portal referencing a glide query result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2024 01:40 AM
I've added a 'Contact Us' custom header link to our customer portal to provide a link to a knowledge article, with each customer knowledge article being unique, and restricted to those company users. The customer specific knowledge article is specified on a custom reference field on their company page, and I'm using a glide query to identify the company of the logged in user and obtain the referenced KB Article.
I originally added a scripted link in the menu but the business don't like the fact that there's always a '1' notifier icon showing (as per this community post) so I've suggested adding the link in the header instead of the menu, purely as an alternative way to provide a link which won't show that icon. However, how do I add a glide query script into the footer to be used and provide the right sys_id as a link? I foolishly thought this would be easier than I'm finding.
The HTML on the header works fine, but is currently set as a 'a href' link to google whilst I try to figure this out:
<li class="nav navbar-nav"><span><a href="www.google.com" style="color:rgb(255,255,255); white-space: nowrap; position:absolute; right: 185px; top:20px;">Contact Us</a></span></li>
The Glide Record query I wrote for the scripted link is as per the following, I appreciate that this might need some tweaking to remove the data references but I can do that later once I figure out how to use a glide record query in the header menu:
data.items=[]; // Array to be displayed when clicked on menu
data.count=1; // Indicates number of records
var company = gs.getUser().getCompanyID();
var companyQuery = new GlideRecord('core_company');
companyQuery.addQuery('sys_id', company);
companyQuery.query();
if (companyQuery.next()){
var obj = {};
obj.title = gs.getMessage(companyQuery.u_support_kb.short_description);
obj.type = 'link';
obj.href = '/csm?id=kb_article&sys_id='+ companyQuery.u_support_kb;
data.items.push(obj);
//data.count++;
}
I'm not a front end developer and typically more used to working within the instance than the portal, so whilst glide record queries are my 'bread and butter' linking them to a portal header entry is hurting my head. Any help would be greatly appreciated as I'm struggling to find any examples via internet search and reviewing product documents. Thanks in advance to anyone who can help with this.