I tried using the duplicate function in my 'edit_record rule', but the problem I encounterd was that this rule was taken over by the new_record rule I also created and which is also true, because when you duplicate an instance the New_record rule also applies to this duplicated instance, so instead of setting the actual_record to 'No' in the edit_rule, the New_record rule overruled this (🙂) Does this make sense?
This problem also occurs with the CREATE function!
But after a some puzzling I now have these two rules on my Claims BO, and this seems to works:
Edit_record rule:
If NOT(Claims IS NEW ) AND
Claims.Case_name WAS CHANGED Then
CREATE Claims WITH
Claims.Case_name=OLD_VALUE(Claims.Case_name),
Claims.Actual_record='No',
Claims.DATE_FROM=OLD_VALUE(Claims.DATE_FROM),
Claims.DATE_TILL=CURRENT_TIMESTAMP
New_record rule:
If Claims IS NEW AND Claims.DATE_TILL IS UNDEFINED Then
Claims.Actual_record='Yes'
Claims.DATE_FROM=CURRENT_TIMESTAMP
The DATE_TILL is the key in these rules. It's value is not set when a new Claims instance is created, so the new_record rule applies. When I now edit such a record and change the case_name-value to something else the edit_record rule applies, a new record is created but the new_record rule does not apply because the DATE_TILL is defined!
Am I completely wrong in my appoach or is it true that using CREATE or DUPLICATE can cause trouble with rules that are defined to initialize new BO's??