Version:
  1. Scripts

    Article: AN0002155 Updated: 09.11.2018 Displayed: 192x

    ObjectGears system supports wide scripting possibilities. Scripts extend possibilities of the basic settings about new more advanced functions. You can perform more sofisticated checks before data saving, work with data, start imports, exports, workflow or jobs.

    All the scripts can work with fundamental functions (object OG). Based on the script type further objects specific for a certain use (see hereinafter) can be used.

    How to write scripts

    ObjectGears system uses for scripting JavaScript language, that is extended by custom objects and data types. Scripting is therefore simple and you need just elementary programming knowledge. We have prepared an overview of particular programming constructions to provide you with basic familiarization.

    Script objects vs. data types

    Please pay attention to some script objects having same names like OG data types. This naming is chosen because of transparency. Script objects contain functions for work with the given data type, whereas data type contains own data of the class, export, import...

    E.g. this notation is used to read a record from the class:

    var dr = OG.DataRow.GetDataById( 10, 100);

    The command is using method GetDataById from the object script OG.DataRow and the method returns data type DataRow.

    Special objects

    There are also other script objectsof the ObjectGears system. They are used for a specific purpose, e.g. for some workflow activities. They are described in another chapter. Here is list of these objects:

    Name Description Used in
    OGWFActualRun Special object for a current running workflow instance. Workflow
    JSWorkflowSeqProperty Object for properties of running workflow instance. Workflow
    OGForm Object for work with page content. Webpart Script
    OGActualDataRow Object for current record (type DataRow). Class rules
    OGActualMessage Object for setting an error message. Class rules
    OGActualExport Current export. Export
    OGActualExportRun Instance of current ongoing export. Export
    OGActualImport Current import. Import
    OGActualImportRun Instance of current ongoing import. Import
    OGActualImportDbTable Name of auxiliary database table for the particular import instance. Import
    OGFilteredDataRowIds List of Id of data records displayed on page Datas.aspx. Class abd query buttons
    OGSelectedDataRowIds List of Id od data records selected (by clicking in the list of records) on page Datas.aspx. Buttons of class and query
    OGPerson Instance of current displayed user. Scripts of administration pages - page  User information
    OGDoFilter() Function for filter application. Scripts of administration pages - page User list
    OGClearFilter() Function for filter cancellation. Scripts of administration pages - page User list
    OGWFForCycle Object for pro setting values in the type For cycle. Activity Cycle
    OGControlOperations List of buttons displayedon toolbar or in the context menu. Scripts at the class, query or page

    Repeated use of scripts

    In case when we need to use certain script several times, we can utilize blocks of scripts, functions of which can be called from various ObjectGears places (buttons, rules, workflow...). Take a look at an example.

    Script testing

    You can use Script window for testing the scripts or for script execution.

    Value conversion to Integer

    The JavaScript interpreter is using data type double for numbers. This has to be taken into account when using ObjectGears system .NET objects, that have data type int? (nullable int). JavaScript interpreter will not perform conversion from double to nullable int. Therefore, use in these cases function ToInt.

    Example:

    Object DataRowFilter has a property Filter_MaximumRows typu int?. If you assign an integer value into it, an error is raised. When you include function ToInt, setting the value will be ok.

    var f = OG.DataRow.GetDataRowFilter(1);

    //successful value setting
    f.Filter_MaximumRows = ToInt(14); 

    //this will cause an error
    f.Filter_MaximumRows = 17;

  2.    ---
    Your rating:
    Rated by users: 0x
  3. Top
SearchTitle
×