Use script includes with Performance Analytics

Amy13
Tera Contributor

Can script includes be used with Performance Analytics? I'm trying to use a dynamic filter on the indicator source and it calls a script include. In the "Preview" button I can see the filter is working -- however, when I run the data jobs, the filter doesn't work. Has anyone experienced something like this?

7 REPLIES 7

In ServiceNow, a script include is a reusable script that can be used across multiple scripts, client scripts, and business rules. It contains functions that can be called from other scripts, and it helps to standardize and centralize the logic used in multiple scripts.

To ensure that a script include is loaded before a data job runs, you can add a "load" statement for the script include in the data job. The "load" statement loads the script include before the data job runs, making its functions available to the data job.

Here is an example of how to load a script include in a data job:

  1. Open the data job in the ServiceNow platform.

  2. In the data job form, locate the "Advanced" tab and click on it.

  3. In the "Advanced" tab, locate the "Pre-processing script" field and click on the "Edit" button.

  4. In the script editor, add a "load" statement for the script include at the beginning of the script. For example, if the script include is named "MyScriptInclude", the load statement would be:

 

 

gs.include("MyScriptInclude");

 

  1. Save the script and exit the script editor.

By adding the "load" statement for the script include in the pre-processing script of the data job, the script include will be loaded before the data is fetched and the filter is applied, making its functions available for use in the data job.

 
 
I hope this clarifies your question. 
 

Please mark my answer correct/helpful in case it adds value and moves you a step closer to your desired ServiceNow solution goal. 

Thanks,
Punit

 

Amy13
Tera Contributor

Hi Punit,

What table is this data job on? I'm not sure what data job you're referring to, as I don't see the Advanced tab on the PA job form. Thank you!

Sorry for the confusion around the terms , but I mean to say a- In ServiceNow, a data job is a type of process that is used to perform large-scale data operations. Data jobs are typically used to automate tasks such as data imports, data exports, data transformations, and data migrations.

 

Refer attached screenshot, see highlighted section . 

 

Please mark my answer correct/helpful in case it adds value and moves you a step closer to your desired ServiceNow solution goal. 

Thanks,
PunitJobs.PNG