Show KB articles as hyperlinks in the Portal Forms

Applies to: SharePoint online and On-Premises

Description

In Crow Canyon Service Request application, “Related KB Articles” is a multi-lookup column in Tickets list. In portal forms lookup columns are not hyperlinked and so users cannot open them to see the details. Hyperlinks are removed as by default these will refer to backend site links and we cannot navigate the portal users to the backend site.

This article describes a solution with custom script to show “Related KB Articles” as hyperlinks in the portal Ticket form. These hyperlinks will refer to portal KB forms so that user stays in the portal site while viewing these KB articles.

Detailed Steps

Note: This articles assumes that “Related KB Articles” column is added in Portal Ticket list forms.

Go to Portal site -> Portal Settings -> Portal Forms -> Edit Tickets list forms and it will navigate to Tickets list NITRO forms designer settings page.

Switch to Tickets display form -> Advanced Section -> Custom JavaScript -> Modify the below script as needed and add the script in Custom Javascript Eval section.

Script

if ($('#ccs_control_RelatedKBArticles').text()) {
var lookupValues = currentItem.get_item("RelatedKBArticles");
if (lookupValues != null && lookupValues.length > 0) {
var ccs_KB_Links = "";
for (var index = 0; index < lookupValues.length; index++) {
var kbLookupId = lookupValues[index].get_lookupId();
var kbLookupValue = lookupValues[index].get_lookupValue()

if (kbLookupId && kbLookupId != '') {
kbLookupValue = (!kbLookupValue || kbLookupValue == '') ? kbLookupId : kbLookupValue;
ccs_KB_Links += ccs_KB_Links ? ";" : "";
ccs_KB_Links += "<a target='_blank' href ='https://contoso.sharepoint.com/sites/NITRO/ITPremium/portal/SitePages/DisplayForm.aspx?lfid=8&FormKey=Knowledge%20Base&ItemID=" + kbLookupId + "'>" + kbLookupValue + "</a>";
}
}

$('#ccs_control_RelatedKBArticles').html(ccs_KB_Links);
}
}
functionCallback();

Note:

  1. In the above script replace “RelatedKBArticles” with internal name of the related KB articles column in the Tickets list
  2. Replace the Knowledge Base article link with corresponding Knowledge Base portal display form URL as per below steps:
    • Go to Portal Settings -> Portal Forms -> Edit Knowledge Base list forms -> Click “Copy Knowledge Base URL” button, it will copy the New Form URL. After this modify the New Form URL as below
    • Copied New Form URL: https://contoso.sharepoint.com/sites/NITRO/ITPremium/Portal/SitePages/NewForm.aspx?lfid=2&FormKey=Knowledge%20Base
    • Change to Display Form URL: https://contoso.sharepoint.com/sites/NITRO/ITPremium/Portal/SitePages/DisplayForm.aspx?lfid=2&FormKey=Knowledge%20Base&ItemID=