1. Restrictions by rules

    Article: AN0001866Updated:

    Rules, which has to be met before record save, can be defined on the class. In the section Condition we define expression that has to be evaluated as true in order that the record can be saved. Values from particular columns can be obtained by the function column('column_code').

    Furthermore, it is possible to start a script before record save which enables to handle also difficult complex situation.

    Regular expressions

    We can use function ismatchregex in the condition and solve e.g. correctness of the value entered as a MAC address:

    not(ismatchregex(column('shorttext'),'[0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f]'))

    Record uniqueness

    If we want to ensure uniqueness of the values in a column or combination of columns, we will use rule Before new/existing record save: Start a script that will check current values in the class. Script shown hereinafter ensures that in the given column of the given class is each value only once:

    var s = OGActualDataRow.GetCol_SmallText2(3352);
       if ( s != '')
       {
          var f = OG.DataRow.GetDataRowFilter(251);
          f.SetColumnData( 3352, s);
          f.Filter_OnlyActive = true;
          if ( OG.DataRow.ExistRowByFilter(f))
          OGActualMessage.SetError( 'Error, "' + s + '" is already created.');
             return true;
          }
       }

×