Automatically update document field via computation rule

Hi guys,

I am using A12 in the 2023.06-ext4 version.

My document model contains a computed field, which is currently only once computed by a computation rule inside a CDM when creating a new document or updating an existing one.

In my case, I need the computed field to be always up-to-date, without having to manually select the document and updating it via the UI.

For example, a Server-Side Job that runs f.ex. once a day, does its computation and writes it into the document field would probably be a solution (although I could imagine performance issues arise when there are lots of documents?).

Or maybe it’s possible to calculate the value when loading the document from the server in some sort of event listener?

I’m unsure if these two ideas would work when the computation requires fields from multiple document-models within a CDM?

But I’d also like to know if there is already a build in solution to this problem? Maybe there is a way to configure a computation rule in the SME so that it fits my requirements?

Hi @raffael-broad-linden,

The Kernel Language can do great things, but the triggers for computations have defaults which are linked to our interaction with the form in our application.

A developer can certainly use these triggers to customize when your computation is carried out. For example, this question was asked relating to a custom trigger, Is there a way when updating the Activity form to also trigger the computations?

If you want to do this over the backend, please start another thread in the Data Services category.

Hi @malcolm-silver-ice,

thank you for the response!

I’m not sure if the FE is the right place to do it in my case.

I have changed the product to Data Services for this thread.

Hi,
In data service, there is a method to compute document com.mgmtp.a12.dataservices.document.internal.kernel.KernelDocumentService#computeDocument
If you want to do it with cdd, you can refer using it in here `

com.mgmtp.a12.dataservices.cdd.internal.CddFactory#constructCdd
com.mgmtp.a12.dataservices.cdd.internal.CddDirtyDocumentsConsumer#createAndUpdateCdd

Note: Be aware that updating cdd within updating index data will lead to a performance issue. Therefore, If you have many document, I suggest you don’t do this daily.

Hi @phuoc-sleek-sand

Thanks for your response!

Just to clarify, do you mean that updating many CDDs can cause performance issues during the update or after the update?

It is the performance issue about indexing. It will take time, and DB resources (CPU) to index CDD. After the indexing finished, everything should be fined.
You should understand about which cdd mode (sync/async) you are using. With async mode, after the document is updated in DB, the indexing process may still be running in background.

Alright, thank you.

How do I know if I am using sync or async CDD mode?

Please refer a12 document:

Thank you!

And I am curious if there is any recommendation on when to use async or sync mode?

Hi @raffael-broad-linden,

In docs, DS team has cautiously mentioned

CAUTION: Processing of CDD has an unpredictable impact on performance because it depends on structure and amount of the data, so it is not recommended to enable synchronous processing in the production environment until you investigate the impacts. This flag is controlling processing of CDDs during document and link changes as well as during initial index rebuilding. This flag is controlling processing of CDDs during document and link changes and also during initial index rebuilding.

Dear @raffael-broad-linden ,

were the responses helpful and is the issue now solved or are there some additional questions? If it is solved, please, use the checkbox to mark the solution to your problem so that other users also know what helped to your case.

Denise from the Discourse team