Miscellaneous - Useful Coding Tricks

reviewed: 6 November 2025

Checking for Period Overlap

  • BO has start- and end date
  • You want to check that BO period does not overlap with other periods
    // Example of use in _eventAction
    bo.exists(
            'scheme/yearOfAccount',
            'id<>{ bo.pk( [_me] ) } & startDate<{ bo.attr( [_me], "endDate" ) } & endDate>{ bo.attr( [_me], "startDate" ) }'
        )

            |--------------| (1)
    |--------------| (2)
                        |--------------| (3)
        |--------------------| (4)
                |------| (5)

  1. Existing period
  2. Wrong as ends within existing period
  3. Wrong as starts within existing period
  4. Wrong as starts before existing period and ends after existing period
  5. Wrong as starts after existing period and ends before existing period

New period is wrong if:

Other period exists where startDate < new.endDate and endDate > new.startDate