KB Article view count increasing with count 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2022 10:59 PM
HI ,
There is one issue we are facing . Regarding the number of views counted when reading a knowledge article, its counting view twice when we try to view the kb from UI action link on the KB form .If we directly search the KB in portal with the KB number, it increases view count by 1, which is as expected. but for the UI action link its increasing twice.
I searched in : respected widget found below script details, please let me know where do i have to make changes,
KBViewModel =>KBViewModelSNC
Script :
increaseKBView: function(knowledgeRecord) {
if (!this.isPreviewArticle() && knowledgeRecord && knowledgeRecord.isValid()){
knowledgeRecord.incrementViewCount();
new sn_ais.IndexEvent().queueUpdatableFieldAction('kb_knowledge', knowledgeRecord.getUniqueValue());
}
},
incrementAndReturnKBView: function(knowledgeRecord){
this.increaseKBView(knowledgeRecord);
var kbArticleGr = new GlideRecord('kb_knowledge');
kbArticleGr.get(knowledgeRecord.sys_id);
if(kbArticleGr)
return kbArticleGr.getValue('sys_view_count');
},
The UI action link takes values of URL from a Business rule via scratchpad object. Is that affecting the count? What we observed is that , 1st the half of the portal page loads, KB article view count increases by 1 & again when the page loads completely with the KB sys_id in its URL, again the count increased by 1 in just fraction of seconds. Hence its increasing view count by 2. Which is weird.
Please if anyone can guide me. Where do I have to make changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 08:12 AM - edited ‎01-26-2023 12:53 AM
Hello Abhilash Janga1,
I had a similar issue on the KB portal with the view count increasing twice. I found that the issue was coming from a widget call "Knowlegde Top Article" in which there was the same script as in the "Knowledge Article content". So I recommend you to check the code in the different widget, you might find what you are looking for.
In my case, I commented out in the "Knowledge Top article" widget, this part of the code in the server script :
function handleViewCountIncrement(){
var incrementedViewCount = new global.KBViewModel().incrementAndReturnKBView(knowledgeRecord);
if(incrementedViewCount)
data.viewCount = parseInt(incrementedViewCount);
}
and also this line where the function " handleViewCountIncrement()" is called.
I hope this will help you.
Thanks and regards,