On this Page

    -script

    (Mandatory)

    A JavaScript file to be used for Job Name Discovery (JND).

    Syntax

    -script filename

    Description

    The -script option specifies the JavaScript file to be executed to discover the job name. Commonly called the "JND" script. This job name is subsequently used to identify a second script that is used to process the data file.

    The JND script is intended to examine the supplied data file (identified in _job.datafile) and compute which job name applies. E.g, is it an "Invoice" job or a "Statement" job, etc.? Typically this is done by looking at the first few lines of the data file for some identifying string. Often, for XML files, it is the root tag name. For field-nominated format files, it is often the job name in the ^job card, but you can use whatever technique you like to identify which job name to apply to the given data file.

    The JND script's task is to return a string that identifies the job name. E.g.

         return "Invoice"; 

    If the script cannot identify an applicable job name it should: return ""; That will cause the job to fail with error code 84 (and the data file to be saved in the designated ErrorFolder).

    If the script does return a name then the Folder Monitor (FM) processing will look for a job processing script (JPS) in the designated scriptFolder . The JPS file name is the provided job name concatenated with ".wjs". For example, if the JND returned "Invoice" then the FM processing would look for a file named "Invoice.wjs" in the folder identified by the -scriptFolder option. If that file is found, that script will be launched and its eventual return code will determine whether FM considers the job to have succeeded or failed. The JPS can perform many, many steps. It's completely open-ended. Typically it does include a DocOrigin Merge step.

    If the job processing script (JPS) file is not found, FM will revert to using $E/Default-JobProcessing.wjs. Note that that default script has a ##include $O/JobProcessing.wjs and so if you have created such an override file, that override script will be used.

    Besides identifying the job name to apply, the JND can also set arbitrarily named properties in the _job.options object. The _job.options object is available to the JPS when it is run. As it happens, the JND can also set user-chosen global JavaScript variables. Those too are available to the JPS. Note that neither the global variables nor the _job.options object are available to the scripts defined in a form design. Merge is a different process than FM and so does not have access to that information. Typical information that you might store in the _job.options object are items gleaned off of the ^job card when using a field-nominated format data file.

    If the data file is XML and has a DocOrigin processing instruction that includes a job=xxx attribute, then this -script option will be entirely ignored. No JND script will be run as the job attribute tells FM which JPS to run.

    See Also

    Command Line Processing
    Command Options - FolderMonitor
    Job Name Discovery
    _job Script Object