Count Distinct PA Script of Knowledge Used on Incidents

Chelsea Moore
Tera Guru

Hi All,

 

I attempting to create a PA script to find the count distinct of knowledge articles marked as either this helped or attach on incidents. To do this, I know I need to query the cxs_relevant_doc_task table to find out if the incident was marked this helped or attach. Then I want to get the COUNT DISTINCT aggregate of the incident number for my automated indicator. I wrote the script below but I'm getting an error when I run the job to test "Error during JavaScript evaluation com.snc.pa.dc.ScriptException: JavaScript evaluation returned: Undefined in script". Any help with this code would be appreciated!

 

function incWithKnowledgeUsed() {
   var totalINC;
    var gr = new GlideRecord('cxs_relevant_doc_task');
    gr.addEncodedQuery('task_number=current.number^detail_relevanceINThis helped,attach');
    gr.query();
    gs.log(gr.getRowCount());

    if (gr.next()) {
        var ga = new GlideAggregate('incident');
        ga.addAggregate('COUNT(DISTINCT', 'number');
        ga.query();

        if (ga.next()) {
          totalINC = ga.getAggregate('COUNT(DISTINCT', 'sys_id');
        gs.info(totalINC);
      }
    }

   return totalINC;

}
0 REPLIES 0