- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 06:35 AM
Hi All,
I followed workaround provided in below KB article.
ServiceNow KB: Contextual search on record producers does not work in Service Portal (KB0610534)
It is working fine in portal for KB articles but when we click on any catalog item which were there in search results then the links are redirecting again to the same form instead of respective form.
for example, i opened 'Create incident' and if i type 'Laptop' in field then i am getting catalog item results. But, when i click on links (all catalog items) it is redirecting to the same(Create incident) form
I have added target='_blank' attribute for anchor tag to open in new tab.
Please help me to solve this issue.
widget html code:
<sp-panel ng-if="c.data.valid" class="cxs_results_panel">
<!-- VCR controls for results -->
<div ng-if="c.data.results.length > 0" class="cxs_results_vcr row">
<div class="col-md-9">
{{form.results_header_text}}
</div>
<span class="cxs_results_vcr col-md-3 pull-right">
<button name="vcr_first" data-nav="true" id="cxs_results_first" title="${First page}" class="btn btn-default btn-icon" ng-disabled="!isPreviousValid()" ng-click="firstPage()">
<span class="glyphicon glyphicon-backward"></span>
</button>
<button name="vcr_back" data-nav="true" id="cxs_results_back" title="${Previous page}" class="btn btn-default btn-icon" ng-disabled="!isPreviousValid()" ng-click="previousPage()">
<span class="glyphicon glyphicon-triangle-left"></span>
</button>
<div class="vcr_controls">
<span class="list_row_number_input">
<span id="cxs_results_first_row">{{data.searchConfig.currentOffset + 1}}</span>
${to}
<span id="cxs_results_last_row">{{data.searchConfig.end}}</span>
</span>
</div>
<button name="vcr_next" data-nav="true" id="cxs_results_next" title="${Next page}" class="btn btn-default btn-icon" ng-disabled="!isNextValid()" ng-click="nextPage()">
<span aria-hidden="true" class="glyphicon glyphicon-triangle-right"></span>
</button>
</span>
</div>
<!-- Handle Search Results -->
<div ng-repeat="result in c.data.results" class="m-b row">
<!-- Knowledge Articles -->
<div ng-if="result.meta.source == 'knowledge'" class="cxs_result_container">
<div class="row">
<div class="cxs_result_title">
<a href="{{result.meta.link}}" target='_blank'><span ng-bind-html="result.title"></span></a>
</div>
<div class="cxs_meta_row">
<span class="breadcrumbs">
<span>${Knowledge Base}: {{result.meta.knowledgeBase}}</span>
<span role="separator">|</span> <span>Category: {{result.meta.parentCategories.splice().reverse().join(' > ')}}</span>
</span>
</div>
<div class="cxs_meta_row">
<ul class="cxs_article_info">
<li><i class="glyphicon glyphicon-user"></i> ${Author}: {{result.meta.author}}</li>
<li><i class="glyphicon glyphicon-calendar"></i> ${Published}: {{result.meta.published}}</li>
<li><i class="fa fa-circle"></i>
<span class="rating_container">${Rating}:
<div data-ng-repeat="i in [1,2,3,4,5]" class="cxs_rating_readonly" aria-hidden="true">
<span ng-if="result.meta.rating >= i" class='active-star'>★</span>
<span ng-if="!(result.meta.rating >= i)" class='inactive-star'>★</span>
</div>
</span>
</li>
</ul>
</div>
<div class="cxs_result_snippet">
<span ng-bind-html="result.snippet"></span>
</div>
</div>
</div>
<!-- Service Catalog Items -->
<div ng-if="result.meta.source == 'catalog'" class="cxs_result_container">
<div class="row">
<div class="cxs_result_title">
<a href="{{result.meta.link}}" target='_blank'><span ng-bind-html="result.title"></span></a>
</div>
<div class="cxs_result_snippet">
<span ng-bind-html="result.snippet"></span>
</div>
<div ng-if="!result.meta.preview" ng-init="result.meta.preview=false" class="cxs_result_preview">
<span ng-click="result.meta.preview=true">
<i class="fa fa-chevron-right"></i> ${upper_preview}
</span>
</div>
<div ng-if="result.meta.preview" class="cxs_result_preview">
<span ng-click="result.meta.preview=false">
<i class="fa fa-chevron-down" ></i> ${upper_preview}
<div class="cxs_result_content">
<div class="cxs_result_image col-md-3">
<img title="{{result.title}}" src="{{result.image.link}}" class="cxs_result_image" />
</div>
<div class="cxs_result_description col-md-9">
<span ng-bind-html="result.meta.description"></span>
</div>
</div>
</span>
</div>
</div>
</div>
<!-- Social Q and A -->
<div ng-if="result.meta.source == 'social'" class="cxs_result_container">
<div class="row">
<div class="cxs_result_content col-md-10">
<div class="cxs_result_title">
<a href="{{result.meta.link}}"><span ng-bind-html="result.title"></span></a>
</div>
<div class="cxs_meta_row">
<ul class="cxs_article_info">
<li>${Asked by}: {{result.meta.author}}</li>
<li><i class="fa fa-circle" aria-hidden="true"></i> {{result.meta.viewCount}} ${Views}</li>
</ul>
</div>
<div class="cxs_result_snippet">
<span ng-bind-html="result.snippet"></span>
</div>
</div>
<div class="cxs_result_image col-md-2">
<div class="question_stats_box">
<div class="side-box">
<div class="box" style="width: 47%;">
<div class="number-box">{{result.meta.votes}}</div>
<div class="text-box">${vote}</div>
</div>
<div class="box" style="width: 47%;">
<div class="number-box">{{result.meta.answerCount}}</div>
<div class="text-box">${Answer}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div ng-if="(c.data.results.length == 0)">${No matching results found for '{{data.freetext}}'}</div>
</sp-panel>
Thanks and regards
Swamy
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 07:01 AM
I didn't realize it before but it seems the XML provided in the KB may be buggy!
In the <!-- Service Catalog Items --> section of the HTML Template code, you need to update the href of the link. In my case, I updated it to:
<a href="sp?id=sc_cat_item&sys_id={{result.id.split(':')[1]}}"><span ng-bind-html="result.title"></span></a>
You may need to customize the sp?id=sc_cat_item&sys_id= part of the link with your Service Portal base (sp) and page (sc_cat_item). The {{result.id.split(':')[1]}} of the URL is the sys_id of the Catalog Item.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 07:01 AM
I didn't realize it before but it seems the XML provided in the KB may be buggy!
In the <!-- Service Catalog Items --> section of the HTML Template code, you need to update the href of the link. In my case, I updated it to:
<a href="sp?id=sc_cat_item&sys_id={{result.id.split(':')[1]}}"><span ng-bind-html="result.title"></span></a>
You may need to customize the sp?id=sc_cat_item&sys_id= part of the link with your Service Portal base (sp) and page (sc_cat_item). The {{result.id.split(':')[1]}} of the URL is the sys_id of the Catalog Item.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 07:05 AM
Also tagging ctomasi and teenasingh - Chuck/Tina can you help communicate this issue to the person/team who can help fix the KB and the provided XML?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 08:21 AM
Nia,
I am contacting the KB Author to see if there might be a fix. Thank you.
Stay tuned.
Regards,
Teena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 06:29 AM
The prb692368-workaround-sp-widget.xml file on KB0610534 has been updated to resolve the issue. The changes made can be seen below:
This fix applies to Knowledge Articles, Catalog Items and Social Q and A sections. i.e. Change all occurrences of:
<div class="cxs_result_title">
<a href="{{result.meta.link}}">
with:
<div class="cxs_result_title">
<a href="{{result.cxsLink}}">