How to validate whole form when adding new record

We have form and we want to have only one record with boolean setted to true. Imagine it as only one record can be saved as “IsActive”. We approaced this with ConfirmationRule on menu item but it seems that it gets only the newly added record, so we can’t do something like count all record with IsActive = ‘true’.

What is correct approach to validate whole form?

  1. find the entity of the recods and then the IsActive field. Right-click on it and create a filter with a parameter out from that column
  2. Create a new lookup based on the record’s entity (default one), but name it special (e.g. EntityName_ActiveCount
  3. Go to the lookup’s datastructure and at GetId filterset remove the filter ‘GetId’ and add the one you have created in step 1 (GetIsActive). You can also rename the filterset name if you want to make it clear it’s filtered by IsActive.
  4. Remove ‘Name’ column from lookup datastructure
  5. Set aggregation ‘Count’ for ‘Id’ column at the same datastructure. Name it e.g.‘Id_Count’
  6. Go to the lookup details and change all values containing ‘Name’ to ‘Id_Count’
  7. Your final rule condition should look like ‘AS:LookupValue(‘xxxx-xxxx-xxxx-xxxx-xxxx’, ‘true’) > 1’ (you run the lookup and the lookup returns the number of Active=true records). If it is greater then 1, show the error message