[CDM] How do I copy a value from a field in one document to a field (located in a repeatable group) in another document?"

Hi,

I have a CDM document, it includes Contract and Compensation documents. The relationship between Contract and Compensation is one-to-many.
Contract has field names CountryEmploy, and Compensation document has field names Currency.
The value of Currency is depended on CountryEmploy, so I have calcuation like this:

But I got error:
“Error
The error field ‘/ContractCompensation/Compensation/Currency’ is not in the rule group, but the condition specifies iteration. [MVK_ERROR_FIELD_NOT_IN_RULEGROUP]”

Do you have any idea or suggestion for this? Thanks!

Oops, the title doesn’t really matched with the description, so let me give one more example: I want to copy value from Contract/StartDate to Compensation/ValidFrom when Contract/Status is ‘draft’, If I use computation in that case I got the same error.

Hi @nguyen-sharp-drift,

Your issue here is to do with repeatability. You need the repeatability of your rule and computed field to match up.

In the majority of cases, the Computation Rule Editor and the Kernel can work out that you have a repeatable Computed Field, and therefore you want to calculate the result between 0 and 100 times depending on whether the repeatable group has been filled or not.

As the Error says, the Computation Rule Editor cannot work this out because the Computation Rule and the Calculated Field are in different Groups.

[MVK_ERROR_FIELD_NOT_IN_RULEGROUP]

If you put the Computation Rule in the Group “ContractCompensation”, then the Rule will be in the correct repeatable Context.

Please Note
I would strongly recommend adapting the precondition to

FieldFilled(t_docRef) And [/Contract/CountryEmply] == "de"

using the technical Field “t_docRef” to check whether a Compensation Document has been linked. See here for more details. You need to model the string Field, t_docRef, in the Group “ContractCompensation” and then adapt the Precondition as suggested.

My answer remains the same.

  1. Move the rule into the repeatable context
  2. Add the check, using t_docRef, to ensure a link has benn established

Thank you for your prompt help, I’ll try this.

Hi, I can add field t_docRef to ContractCompensation group, but I still don’t know when & how this field is filled? Could you give me some hints? Many thanks!

I was just speaking to a colleague about this as there is a bit of missing documentation in the 2023.06 docs which you are working from.

The field t_docRef is automatically filled by the client when a relationship link is present. This is useful for rules that are triggered on the client side. Having spoken to my colleague, he reminded me that it’s not necessary for repeatable contexts like yours as the Kernel is adding the precondition GroupFilled(RuleGroup) to the Computation Rule anyway. Thanks @felix-blazing-river!

The missing note in the documentation is that the t_docRef Field is never filled server side. You can see this here. This means that if you choose to add this field, your rule would never fire on server side.

TLDR - t_docRef is automatically filled on Client side but the value is not saved and it is always empty on server side.