Passing global variables between sections and to control scripts

Are control scripts and enabling sections only available as the first thing that happens with a new record?

Is there a better way?
I’d like to conditionally enable a section based on very complex scripts that execute on a previous section. It appears that the control scripts have already been evaluated by this time though.

Update…_____________

The content I need to hide and show is listed in a JSON file. I’ve not had any luck pulling that into a control script although it does load well in other scripts. Can I extend the datamapper with a table or 2 created from the Jason data? Fields of course are available to the control script.


As I’ve toyed with global variables I’ve come to these understandings which might not be totally acurate.

  1. Job infos are available across all sections and all records

  2. Control scripts and global variables created in them are evaluated only at the “on read” of a record. Although those variables can be used in all sections just not for controlling.

  3. Global variables defined with head as the selector are available to all sections, current record only, also not for section control.

  4. Global variables defined with body as the selector are only available for the current section

Hello SStClair,

Correct, Control Scripts are evaluated before the other scripts and once per record. They run before the pagination process starts and are typically used to control the high level objects like print/skip sections, dynamically set section backgrounds and control email attachments based on print sections. Control Scripts have access to the Data Model, so one can provide the JSON data as the value of a data field and use that data to define which sections to skip or print.

Variables instantiated in a Control Script can be used and altered by ‘normal’ scripts. Keep in mind that these scripts are executed after the Control Scripts and in the order they appear in the Scripts panel.

    1. Not entirely sure what you mean with variables with head as selector. Are you referring to scripts with head or body as selector? Typically scripts are executed for each section (and master pages) unless you create a folder with an execution scope (e.g. create a folder in the Scripts panel, right mouse click that folder and choose Properties) or setup a selector that references a specific section (e.g. html[section=‘Section 1’]).

Hope this is of some help,

Erik