1. Script for reading parameters from URL

    Article: AN0001916Updated: 21.01.2020

    It is possible to pass the values between pages by means of URL parameters. URL can contain more parameters that are separated by character &.

    You do not have to pass the values via URL but just ID of an existing record that you can read in the rule and get requested values out of it.

    Example of URL request with two parameters:

    https://www.objectgears.cz/DataDetail.aspx?id=16-100&name=og&number=39

    Use following functions for reading values and conversion to the appropriate data type.

    Where to use this script: Rules of type Script, Scripts in class detail, Script in page detail, Webpart Script, Script call...

    var s = OG.QueryString.GetString('name');
    var i = OG.QueryString.GetInt('number');
    var d = OG.QueryString.GetDateTime('name');
    var g = OG.QueryString.GetGuid('name');
    var b = OG.QueryString.Exist('name');

    Setting up values in DataRow before displaying a new record in detail

    Examples of scripts for the rule Before displaying new record in detail, that will process URL parameters and fills in corresponding control (record field). There are various names of URL parameters (varFrom, varCenter atd.) used in the examples and various column codes (datetimefrom, center). In certain cases scripts work also with code of a referred class (center...).

    Column type Display type Script
    Text   OGActualDataRow['name'] = OG.QueryString.GetString('varName');
    True/Untrue  

    OGActualDataRow['active'] = OG.QueryString.GetString('varActive') == 'A';

    OGActualDataRow['active'] = OG.QueryString.GetInt('varActive') == 1;

    Integer   OGActualDataRow['count'] = OG.QueryString.GetInt('varCount');
    Decimal   OGActualDataRow['price'] = OG.QueryString.GetInt('varPrice');
    Files   Not supported.
    Date and time   OGActualDataRow['datetimefrom'] = OG.QueryString.GetDateTime('varFrom', 'dd/MM/yyyy');
    Guid   GActualDataRow['gid'] = OG.QueryString.GetGuid('varId');
    Value from a referenced class (reference to class) - simple reference Combobox *) OGActualDataRow['center'] = OG.QueryString.GetInt('varCenter');
    Value from a referenced class (reference to class) - simple reference Vyhledávací formulář *) var clCenter = OGDataParent.Model.ClassDefs['center'];
    var id = OG.QueryString.GetInt('varCenter');
    OGActualDataRow['center'] = OG.DataRow.GetDataById(clCenter.Id, id);
    Value from a referenced class (reference to user) - simple reference Vyhledávací formulář *)

    var pId = OG.QueryString.GetInt('varPerson');

    var p = OG.Person.GetById(pId);

    OGActualDataRow['person'] = p.ToPersonInfo();

    Value from a referenced class (reference to class) - multiple reference  

    var clCenter = OGDataParent.Model.ClassDefs['center'];
    var id = OG.QueryString.GetInt('varCenter');

    var dr = OG.DataRow.GetDataById(clCenter.Id, id);
    OGActualDataRow['center'].Add(dr.ToEntityInfo());

    Value from a referenced class (reference to user) - multiple reference  

    var pId = OG.QueryString.GetInt('varPerson);

    var p = OG.Person.GetById(pId);

    OGActualDataRow['person'].Add( p.ToPersonInfo());

    Reference to a class   OGActualDataRow['class'] = OG.QueryString.GetInt('varClass);
    Value from a referenced class (various classes)  

    var clCenter = OGDataParent.Model.ClassDefs['center'];
    var id = OG.QueryString.GetInt('varCenter');

    var dr = OG.DataRow.GetDataById(clCenter.Id, id);
    OGActualDataRow['center'].Add(dr.ToEntityInfo());

    Colour   OGActualDataRow['color'] = OG.QueryString.GetInt('varColor);
    Picture   OGActualDataRow['image'] = OG.QueryString.GetString('varImage');

    *) When the column is displayed by means of combobox you can insert into the DataRow just the ID of the referred record. When displaying by means of  search form ID cannot be used. It is necessary to insert into the DataRow a DataRow or Person instance.

×