How does variable scope work in pa_scripts and scripted breakdown mappings?

jfuasid
Tera Contributor

I'm hoping someone can explain to me why the following is possible: when running a scheduled data collection, the pa script (for a breakdown mapping) is able to access variable values assigned in previous runs.


For instance, if you have the following code in your pa script...

 

var i;
if (!i) i = 1;
i++;

gs.info('record number '+i);

...i will increment with each record that is processed. 

 

Questions:

  1. Is this intended functionality?
  2. Can someone explain to me what is happening in the background with pa_scripts and scripted bd mappings that enables this?
  3. Is it safe to use this functionality to pass data (such as manual_breakdown sys_ids) between pa_script executions?

 

I would have expected each run to have its own variable scope.

0 REPLIES 0