1. Script object OG.Script

    Article: AN0002190Updated: 23.10.2018

    This object offers functions for work with scripts.

    Script functions

    Name Description
    ResponseContent RunScript(string code, Hashtable parameters) Function executes a script according to the input code and passes over parameters.
    JSScriptParameterList CreateParameterList() Function returns an empty collection for inserting parameters for script execution.
    object Run(string scriptName, string script, JSScriptParameterList pars, IDbTransaction trans) Function executes script.

    When executing the script by method RunScript following parameters are created:

    OGModel - model, to which the executed script belongs.

    OGParameters - contains Hashtable parameters.

    OGResponseContent -  for setting possible text result from the script call.

     

    By means of function Run you can execute a script, that you have already defined or you will dynamically create it. You can pass to the script whatever object by means of parameter pars. This object can be then called from the script itself.

    Object call

    OG.Script

    Example of call

    var ht = OG.CreateHashtable();
    ht.Add( 'name', 'Charles');
    ht.Add( 'age', 31);
    OG.Script.RunScript( 'run1', ht);

    Example of calling custom dynamic script

    In the below example we create first our script in a variable, we add parameters and then we execute the script. As a result full name of a logged person will be written in the log.

    var script = 'OG.Log.Write( MyObject.FullName);';
    var pars = OG.Script.CreateParameterList();
    pars.Add( 'MyObject', OG.Person.GetLoginPerson());
    OG.Script.Run( script, pars, null);

×