In general, rules are executed on repeating rows, just as they are executed on the main Add and Edit screens. However there are some important differences.

  • The first significant difference is that a rule such as:
     

    <== onchange ==>
    RR_FIELD = ‘value’;

    is executed for all repeating rows in existence at the time of the onchange event, in the order of the repeating rows. You can take advantage of this to perform an evaluation of all repeating rows in existence, and then set a value of a field in the main Add and Edit screen based upon what you find. An example of this is that you might have the repeating row field named RELEASE_STATUS with values of New, Open and Closed. There may be any number of repeating rows in existence with any one of these values in each repeating row. The task might be that you want to set the STATUS field on the main Add or Edit screen, to New if any repeating row has the value of New, then secondarily set the STATUS field value to Open if there is no New value on a repeating row, but at least one repeating row has the value of Open. Finally, you might then want to set the STATUS value to Closed when all the values of the repeating rows are Closed. The following rules will achieve this:
     

    <== onchange ==>
    # First, push our changed status to the STATUS field, so we can then trigger a reset
    # based on all repeating row fields, not simply the one that changed
    if (RELEASE_STATUS.{changed}) {
      STATUS = RELEASE_STATUS; }
    # Now do the actual roll up by resetting the main status based on whether specific
    # RELEASE_STATUS values exist. Note that the order of these rules is critical
    if (RELEASE_STATUS = ‘Closed’) {
      STATUS = ‘Closed’; }
    if (RELEASE_STATUS = ‘Open’) {
      STATUS = ‘Open’; }
    if (RELEASE_STATUS = ‘New’) {
      STATUS = ‘New’; }
     

    The rules are executed in order for all rows in the repeating row set. Therefore the last rule will have the last effect, setting New for the STATUS field if any repeating row has the value of New in the RELEASE_STATUS field. This progresses back up the list, so that if all repeating rows have the value of Closed, then the STATUS value is set to Closed

  • You can execute a rule when a new row is added via the Add another button. For example, the rule:
     

    <== onchange ==>
    if (RR_LAYOUT.{changed}) {
      RR_FIELD = ‘value’;
    }

    This has the effect of setting the value of the repeating row field named RR_FIELD on all new rows that are added

  • You can have more finite control, and only execute rules on specific repeating rows through the use of a rule such as:


    <== onchange ==>
    if (RR_LAYOUT.{changed} && RR_LAYOUT.{max_row_num} = 2) {
      RR_FIELD[2] = ‘value’;
    }

    Note the use of max_row_num to determine that the rule is executed only for the row being added. In this example, the rule is only triggered when the third repeating row is added, and the value of RR_FIELD is only set on the third row. Remember, the rows are numbered starting at zero, therefore the number 2 represents the 3rd row