We are currently rethinking our modelling and want to untilze Relationship Models and CDMs.
I am having difficulties with the validation of Forms in the CMD context and I am getting different behaviour when using CMD child activities in the binding and not using child activities.
We have a list of receipts that users can add receipts to so we have a 1-n relation.
We also have the requirement that users have to enter the used cost types on the list. Only cost types entered on the list can be used in the receipts. We have this validation in the CDM and this is where I am struggeling.
The rule itself never fires. When adding a confirm with the same computation as the rule itself it now fires, but only when not using a CDM child activity in the binding. I also have to mark the confirm as global for the rule to fire.
I have also looked at the Redux actions and there I can see that computations are being made on cdd/CHANGE_DOCUMENT when I am not using CDM child activities in the binding and not if CDM child activities are selected. This feels wrong since the documentation and the Info next to the toggle sais to use it if we are creating a new linked object which we are in this case.
Here are the models we are using currently:
Receiptlist_DM.json (4.3 KB)
Receiptlist_AM.json (10.7 KB)
Receipt_DM.json (5.1 KB)
Receiptlist_Receipt_CDM.json (9.3 KB)
Receiptlist_Receipt_CFM.json (9.7 KB)
Now to my concrete questions:
Is this the intended way to model validations in CDM context, or is there a better way?
Is it possible to have a modelling solution that only allows users to select cost types in the receipts that are entered into the receipt list?
Hi @simon-flat-thread
There are so many questions in this one post!
- When do Validation Rules fire?
- Why do Computed Fields cause Validation Rules to behave differently?
- Which Fields are in the scope of validation and when?
and then you add the extra complexity of CDMs on top. The models that you sent we incomplete (missing Type Definition, Relationship, Binding Overviews and Overview Models so we initially not testable. As a result, I’m going to limit my answer to a Test model that I created based on the structures modeled in your model
Validation_DM.json (15.7 KB)
In this model I created 4 rules which you can test yourself using ad hoc test on the Model Tree.
| Rule Name |
Error Condition |
Notes |
| R1 |
FieldFilled(Receipt/CostType) And NoFieldValueIncludedInValueList(Receipt/CostType in ../ReceiptList/ApprovedCostTypes*/CostType) |
Fires on Full Validation |
| R2 |
FieldFilled(Receipt/CostType_Global) And NoFieldValueIncludedInValueList(Receipt/CostType_Global in ../ReceiptList/ApprovedCostTypes*/CostType) |
Fire on Full Validation |
| R3 |
FieldFilled(Receipt/CostType) And NoFieldValueIncludedInValueList(Receipt/CostType in ../ReceiptList/ApprovedCostTypes*/CostType_Global) |
Fires when entering a value into Receipt/CostType |
| R4 |
FieldFilled(Receipt/CostType) And FieldFilled(ComputedConfirm) |
Fires when entering a value into Receipt/CostType |
So why do R3 and R4 fire but R1 and R2 dont?
Why does R3 fire?
- You change the value of
Receipt/CostType. This triggers a partial validation (see here).
- The Scope of this validation is
Receipt/CostType plus and fields changed via computations and/or dependencies plus any global fields (see here). This means that ../ReceiptList/ApprovedCostTypes*/CostType_Global are also in scope.
- The Rule can be evalutaed correctly as all Fields in the rule are in the context of this partial validation (see here).
Why does R4 fire?
- You change the value of
Receipt/CostType. This triggers a partial validation (see here).
- This also triggers a recomputation of
ComputedConfirm as Receipt/CostType is referenced in ComputedConfirmComp.
- As a result, the Rule can be evalutaed correctly as all Fields in the rule are in the context of this partial validation.
Why don’t R1 and R2 fire
The rules use And to join two partial conditions. All fields need to be in the scope of the validation. This only happens on full validaiton.
What about CDMs?
The same rules of scope apply. If you need to validate on the Child Activity, then the Form Model for the Child Activity need to be based on a CDM which references all the relevant data. There’s an example of this in the advanced workspace that comes with the installer. In PersonWithTeamsAndContracts, child activities are used to load a Form PersonsTeamAssignmet_CFM. This CDM based child activity is used as we want to write a validation rule based on field values outside the context of Team_DM.
A similar solution should work for you to.
Further help
If you need further support modeling this, please include a complete set of valid models. This can be shared using an ownCloud link to avoid uploading large quantities of models.
Sorry for not providing all the files, I was limited to 5 files and zip is not allowed.
It seems I dont have access to owncloud. Any other way to provide the workspace?
Yes it is! You just need to combine the learning from my previous post about partial validation and Child activities.
I modeled this all in the 2025.06-ext2 workspace you can download [here]<INTERNAL_LINK>. This workspace splits Validation_DM that we already discussed into Vali_DM and Dation_DM which are linked by a relationship.
Validate on the Child Activity
The validation the the end-user sees depends on Form and Document Model in the current scene. Due to Form Model Locking, the Child Activity will be validated based on the rules modeled on the Document Model that the current Form is based on. This means you need a Child Activity that contains all the relevant fields and rules in the Document Model.
To achieve this you need to model a second CDM for the child activity. In the attached workspace, this is called DationWithVali_CDM.
This CDM contains the relevant rules from the parent CDM, ValiDation_CDM. These are the same rules as already discussed, but renumbered R5-8.
Clicking on “Save” triggered a full validation of the data based on the rules modeled in DationWithVali_CDM as a full validation is modeled for this button. R5-8 all fire as you can see in the screenshot.
Validate immediately on Child Activity
R7 can fire immediately on the child activity as all the Fields referenced in the rules are in the validation context. R7 is equivalent to R3 in the previous post. See “Why does R3 fire”.
Is it necessary to duplicate the Validation Rules on the Child Acitivity?
Yes, if you want the Validation Rulesto fire on the child activity, the rules must be duplicated there.
Can I remove the Validation Rules from the parent CDM?"
No, you should not remove the rules from the parent CDM as the entire Composed Document should be fully validated before it is sent to the server. This happens in “DM As Child” where R1-4 fire when trying to save the Composed Document. This behavior is desireable.