How to call script include in indicator source?

Sathwik1
Tera Guru

How to call script include in indicator source?

In indicator source I am calling script include like below... when I use like below '0' Records are getting.. what's wrong in that..

Sys Id is  one of   javascript: new x_abc_ewtwe_.getAccount().getTasks();

In report the above condition is working as Expected

But in performance analytics if I use the same above condition '0' tasks are getting.. what's wrong in that?

4 REPLIES 4

Sathwik1
Tera Guru

@Ankur Bawiskar 

SAI_JAGADEESH15
Tera Contributor

everything is correct only that is you need specify which access qualifier you are using to call,
Let say your records in global application scope then the code should be
javascript: new global.x_abc_ewtwe_.getAccount().getTasks();

You can refer below image which I attached for

 

Its_Sagnic
Giga Guru

Hi @Sathwik1 ,

Hope you are doing well.

The Solution :

  1. Scope Access: Set the Script Include’s Accessible from field to "All application scopes".
  2. Return Format: PA requires a Comma-Separated String of Sys IDs. If your script returns an Array, PA won't "see" the records.
  3. No Session Logic: Ensure the script doesn't rely on gs.getUserID() or current, as these are often null during background PA collection.

    Example Code Snippet :
     
    1. The Script Include :

    Make sure this is marked Client Callable (if used elsewhere) and All Application Scopes.
     
var getAccount = Class.create();
getAccount.prototype = {
    initialize: function() {},

    getTasks: function() {
        var taskIds = [];
        var gr = new GlideRecord('task');
        // Example: Fetching active tasks for a specific account
        gr.addActiveQuery();
        gr.query();

        while (gr.next()) {
            taskIds.push(gr.getUniqueValue());
        }

        // CRITICAL: PA needs a String, not an Array object
        return taskIds.join(','); 
    },

    type: 'getAccount'
};
 

 

The Indicator Source Condition :

In the condition builder for your Indicator Source:
  • Field: Sys ID
  • Operator: is one of
  • Value: javascript:new x_abc_ewtwe_.getAccount().getTasks();


Try the solution above.. If the solution is helpful for you please accept it and mark it as helpful.

Regards,

Sagnic

Hello use the below format
javascript:new global.x_abc_ewtwe_.getAccount().getTasks();

 
the above one will work smooth please follow below image 
while pasting its a typo error for the previous one

2026-03-21_10h42_58.png