Prevent double instances of nodes

In my application a double registration of a relation as well as an invoice has to be prevented.
I’ve tried this by using the combination of postcode with house number as relation number.
for invoices it wil be the combination of relation number and invoice number to create an unique registration.

This seems possible but it generates two new problems:

  1. only one office of a group of “small” organisations, who are situated in one and the same building, can be registered.
  2. sometimes a “normal” house can be divided in more appartments and have a number of different additions which make a double registration still possible.

How can these problems be addressed in Alan?

root {
 	'Relaties': collection ['RelatieNr'] {
		'HuisNr': text  @description: "bijvoorbeeld: 123, 123A..Z of 123-1H"
		'Postcode': text @validate: "^(\\d){4}([A-Z]{2})$" @description: "1234AB"
		'RelatieNr': text @description: "Postcode + HuisNr: 1234AB123"
  'Nieuwe Relatie': action {
		'HuisNr': text  @description: "bijvoorbeeld: 123, 123A..Z of 123-1H"
		'Postcode': text @validate: "^(\\d){4}([A-Z]{2})$" @description: "1234AB"
		'RelatieNr': text @description: "Postcode + HuisNr, zonder spaties"
	} => update .'Relaties' = create (
		'HuisNr'= @ .'HuisNr'
		'Postcode'= @ .'Postcode'
		'RelatieNr'= concat ( @ .'Postcode', @ .'HuisNr' ) // 'RelatieNr'

First of all, you can do this for the 'Relaties' collection

'RelatieNr': text @default: concat ( . 'HuisNr' , . 'Postcode' )

This allows the user to change it when needed (for instance, to add something to separate customers on the same address).

There is no way to always prevent a double registration, there could be a type error in play as well. The best way to handle that is for the user to be able to fix incorrect/double entries later on.

The default is an excellent idea.
Adding (if in future possible and available) some sort of ‘masking’, showing the user what’s possible before entering anything will formalize the entry options even more.


By the way: I think you should be able te remove the action after this change as well.