- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 07:15 PM
The business has asked if it is possible to hide unpublished knowledge articles on the Service Portal for users but not affect the back end client search. The requirement is so that users have the same experience as customers do when using the portal,
I understand the following setting within properties, but unticking this option will not allow users to search related articles within incidents etc.
Our portal has been setup to use a Typehead Search widget with SNC.SearchRequest and from what I understand there would be no way to pass a parameter into it to only return published articles as the following seems to be the only rules that can be applied
- knowledgeBase
- topic
- category
- language
- department
I might be looking at this from the wrong perspective so any help directing me to another way of doing this would be greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 06:45 PM
For anyone interested in knowing the outcome - I was looking at it the completely wrong way.
I was given a lead to look at the Service Portal -> Search Sources
In my Knowledge search source I was able to add an extra part to the encoded query - + "^workflow_state=published".
Adding this removed the results from the search and from the categories listing but had no affect on the client side.
Using ACLs or User Criteria did not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2022 07:57 AM
I was trying to pre-filter knowledge base search for employee center and finally got it working by adding to the end of:
// return built up query, stripping away leading ^
return (kbQuery.startsWith("^")) ? kbQuery.substring(1) : kbQuery;
So mine looked like:
// return built up query, stripping away leading ^
return (kbQuery.startsWith("^")) ? kbQuery.substring(1) : kbQuery + '^sys_updated_onRELATIVEGT@year@ago@1';
Which by default only displays articles updated a year ago or sooner. Not 100% sure if that's the best approach but it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2022 04:29 PM
Sorry for the delay in responding.
Jesse has updated the script in the same place I did mine.
Under Service Portal -> Search Source I went into Knowledge Bases.
Around line 120 in the Data fetch script is the query that Jesse and I updated.
// return built up query, stripping away leading ^
return (kbQuery.startsWith("^"))? kbQuery.substring(1): kbQuery +
^workflow_state=published";
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2023 08:19 PM
Hi @Phil4
Would you mind to show the details how did you added the condition? I'm also looking for the same solution. Hope you dont mind to share. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 05:33 PM
Hi Suraya82
Sure, head to Service Portal -> Search Source. In the list that appears go to Knowledge Bases.
In the Data fetch script look for the comment "// return built up query, stripping away leading ^"
for me, this was at lines 119 and 120
Your 'Out of the Box' code below this should read
return (kbQuery.startsWith("^"))? kbQuery.substring(1): kbQuery
You can add your own requirements to the end of the code. For me and my initial question, I added + "^workflow_state=published"
So this is my code now.
// return built up query, stripping away leading ^
return (kbQuery.startsWith("^"))? kbQuery.substring(1): kbQuery + "^workflow_state=published";
I hope this explains it better.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 08:08 PM
Phil,
Thank you very much for the reply. I've tried this solution however it is not working for my case. I wanted to remove this warning message from the Portal and this message should not disappear from the backend. Do you happen to know any other solution to my issue?
I've tried this solution as well but the warning disappear both in the portal and backend.
Warning message that is displayed when trying to a... - ServiceNow Community