Need help on pulling a report to find the view count/usage of KB article month wise

Archana23
Tera Contributor

Need help on pulling a report to find the view count/usage of KB article month wise

4 REPLIES 4

dhanrajb
Tera Guru

Hi @Archana23 ,

 

You can make use of "kb_use" table to create your report.

 

Regards,

Dhanraj.

Archana23
Tera Contributor

Archana23_1-1714756351575.png

I have created the same, view count coming here is total number of views of that KB article, but I need the view count of the last 3 months for that KB article.

Oh that's cool....!

 

I believe, you need something like below.

dhanrajb_1-1714763473956.png

 

To recreate this in your instance, create a new field in "kb_use" table. Here I have created a string field called "Month". You can populate that field value using business rule for the upcoming records. But for the existing one you can use Background script. Below I have attached the code snippet, you can make use of it.

 

 

This is for background script,

var kbUse = new GlideRecord('kb_use');
kbUse.addEncodedQuery();
kbUse.query();
var month, newMonth;
while(kbUse.next()){
    month = new GlideDateTime(kbUse.sys_created_on);
    newMonth = month.getMonth();
    kbUse.u_month = newMonth;
    kbUse.update();
}

 

 

 

This is for Business rule,

var month, newMonth;
month = current.sys_created_on;
month = new GlideDateTime(month);
newMonth = month.getMonth();
current.u_month = newMonth;
current.setWorkflow(false);
current.update();

 

Hope this will help you to pull your reports. If yes, please mark my response as solution and give a thumbs up. Cheers....!

 

Regards,

Dhanraj.

Is there any other way instead of creating a new field in kb_use table.