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)
- Existing period
- Wrong as ends within existing period
- Wrong as starts within existing period
- Wrong as starts before existing period and ends after existing period
- 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