DocumentValidationException: Rule with path '/path/to/a/validation': Iteration for '/a/model' is specified, but the rule can fire for not filled repetitions of this repetition level

Hi,

Some of my models are Subsidiary and Company. They are combined with relationship/CDM. Today, after I add a repeatable group to the Subsidiary, plus a validation that at least one value must be set in that repeatable group.

NumberOfFilledGroups(nameInLanguages*) < 1

It looks good, but the app raises one error, complaining about that validation. I can use the app but cannot open that CDM form. I can workaround with a redundant condition related to another field:

NumberOfFilledGroups(nameInLanguages*) < 1 AND FieldFilled(timezone)

The CDM UI looks like this:

The error log is here:

2024-10-16 14:32:14,327 [task-1              ][ERROR][rvices.server.util.KernelCachesPreloader][u:] - pre-compilation failed for document model CompanyCDM
2024-10-16 14:32:14,327 [task-1              ][WARN ][rvices.server.util.KernelCachesPreloader][u:] - Kernel cache pre-loading failed
com.mgmtp.a12.kernel.md.rt.api.DocumentValidationException: Following errors were found while generating code: Rule with path '/SubsidiaryCompany/subsidiary/atLeastOneLanguageRepetition': Iteration for '/SubsidiaryCompany' is specified, but the rule can fire for not filled repetitions of this repetition level. [MVK_NEG_CONDITION_IN_ITERATION]
	at com.mgmtp.a12.kernel.md.rt.internal.service.DocumentModelCodeGenerator.generateCode(DocumentModelCodeGenerator.java:67)
	at com.mgmtp.a12.kernel.md.rt.internal.service.DynamicModelProvider.getModelCode(DynamicModelProvider.java:41)
	at com.mgmtp.a12.kernel.md.rt.internal.service.DynamicModelProvider.getCalculator(DynamicModelProvider.java:32)
	at com.mgmtp.a12.kernel.md.rt.internal.service.DocumentDynamicRtService.precompileDocumentModel(DocumentDynamicRtService.java:24)
	at com.mgmtp.a12.dataservices.server.util.KernelCachesPreloader.lambda$listenOnServicesInitializationFinished$0(KernelCachesPreloader.java:73)
	.......(unrelated to us)
	at com.mgmtp.a12.dataservices.server.util.KernelCachesPreloader.lambda$listenOnServicesInitializationFinished$1(KernelCachesPreloader.java:68)
	at com.mgmtp.a12.uaa.authentication.backend.BackendAuthenticationService.executeWithBackendAuthentication(BackendAuthenticationService.java:52)
	at com.mgmtp.a12.dataservices.server.util.KernelCachesPreloader.listenOnServicesInitializationFinished(KernelCachesPreloader.java:61)

You can see some of our models here:
Subsidiary.json (7.5 KB)
SubsidiaryCompany.json (1.9 KB)
SubsidiaryCDMForm.json (16.4 KB)

What is your suggestion to solve it? Btw, it is good to have a more understandable error message.

Thank you.

Hi @thuan-rocky-core

Looking at your models, you are adding multiple Subsidiaries to a single Company. This means that this Validation Rule exists in a Repeatable context in the CDM.

The Error message that you see

Iteration for '/SubsidiaryCompany' is specified, but the rule can fire for not filled repetitions of this repetition level. [MVK_NEG_CONDITION_IN_ITERATION]

Is described in the latest Documentation here. The solution is to add a check if the repeatable is created.

Could you try

GroupFilled(RuleGroup) And
NumberOfFilledGroups(nameInLanguages*) < 1