Computation fails when a value is already set

Hi,

I am currently facing an issue when the frontend validates my document.
I have a computation with a precondition: activated=true → use field running, activated=false → use field stopped. As an example of course.
I already worked with the document so in my xml I can see that the value for the computated field is already e.g. “stopped”. When I change activated to true, and open the document the next time via the Frontend I get a validationError for the computation. And the only percievable change is that a different value is already present, and it doesn’t like that.

Why does it behave like that, when I change the value activated (even via a documentService implementation, which propagates all the changes)

Sorry for the rough explanation, I am not that well accustomed to A12 keywords and logic.

kind regards
Raiko

Hi @raiko-static-field,
changing the value in the UI should not produce that error unless you are using the constant NOW in your computation as computed value. If you are changing the value programmatically, you also have to make sure that the data in the document is updated properly, e.g. by calling the computation.

I think, that the computation fails because it expects a Field (type confirm) value to be present, which at that point isn’t. Triggering the Computation doesn’t throw the error, the error will be thrown directly after calculating the Computation when validating.
As said, I use the DefaultDocumentService update method from dataservices.

Maybe a better example:
I have the following structure:

  • Computed Field Activated (Type Confirm)

  • Computation Activated_Computation
    activated == true → [Running]
    activated == false → [Stopped]

  • Computed Field Running (Type Confirm)

  • Computation Running_Computation
    activated == true → true

  • Field Stopped (Type Confirm)

Currently “activated” is set to true.
Therfore I have <Activated>True</Activated> and <Running>True</Running>. When I switch activated=false, the computation succeeds, but the validation throws an error with an OMISSION_ERROR for the Activated_Computation.

Basically.

I think I found the issue. I have multiple documents, linked to one another. One contains data of a person, the other contains information from a poll. Answering the poll, or even just loading it computates some data of the poll (activated… etc.) but when I change the activated value to true I update only the person, not the poll. But because this value controls other values of the poll the poll becomes invalid. That’s why the person document can be computed and the validation of the person document fails, because the validation validates also part of the poll, not just data of the person…

That is unfortunate

If you could share the part of your Document Models which are causing the problem, I could see if I can suggest something which could help you.

It looks like, that the behavior is correct, kind of, but it is very irritating. When I get some time, I’ll try to create a small scenario to show the situation.