Accessing the "__meta" fields of an original document inside the CDM

Dear A12 community,

we are using CDMs in our project. For a customer requirement, we need to use the creation date time of the A12 document, in order to do some sorting of the represented documents.

So we noticed the field

“__meta/createdAt”

of the original a12 document. Unfortunately we failed modelling the reference to it in the CDM:

If we inspect the CDM in the debugger, its “__meta/createdAt” is the current date, which is completely different from the original document

Original Document:

"__meta":{
..
"creator": "tech_connector",
"modifier": "tech_connector",
"createdAt": "2024-11-07T12:23:50",
...
}

CDM:

"__meta":{
...
"creator": "superUser",
"modifier": "superUser",
"createdAt": "2024-11-08T12:28:26",
...
}

We also saw A12 ticket A12S-4648 and we hope that our intentions are techically supported by A12 CDMs.

Which is the proper way to access the original documents “_meta” fields from the CDM?

Many thanks in advance!

Hello @sven-low-island,

While Meta Data Fields can be used in Form, Overview or Tree Models; Document Modeling with Meta Data Fields is currently not supported.

If you want to sort the elements in the respective Bindings, you can use the out-of-the-box feature for the Available Items list (just add a respective Column in the Overview Model). To sort the Selected Items list, you need custom code. There is a new API available for this with the newest ext releases of the 2023.06 and 2024.06 release lines.

(Or could you please elaborate a bit further, what “do some sorting of the represented documents” means? Do you want to sort the child documents in the CDM? Or the CDDocuments themself?)

Hello @felix-blazing-river,
thank you for reply and the clear explaination and sorry for giving you not that much information :).

Our use case is as follows:

In our aplication, the Backend (BE) provides a list of items to the Frontend (FE) using our own API.

Every item maps 1<–>1 to a (root) A12 document instance + a CDM instance.

In order to put the items together, the BE makes a LIST_CDDS call to the A12 data Services. The goal of the FE is to sort the items using the creation date time of the documents/items using typescript and react.

We don’t plan to show the document creation time in an overview or form model, as described earlier - we plan only to use it for sorting in react/typescript.

For this reason we intend to use the __meta/createdAt field of the CDM instances. Unfortunately (as described earlier), after the LIST_CDDS call is done, we get CDMS with content __meta/createdAt=“the current time”. The root document on opposite, has correct time in this field.

Our current solution is to create an own new (non meta field) in the root model and copy the __meta/createdAt content to it on document creation. This field is now easy to use in the CDM and the FE gets the right date time, using the new own field. But this solution requires migration of old data (the new own field must be filled with __meta/createAt content for old documents). The solution requres also a lot af modelling for data which is “already there”. This is why we asked if currently is a better way to get the __meta/createdAt date time from the root document to the CDM document.

Thank you and have a nice weekend!

Hey @sven-low-island,

in the Standard Implementation/Preview App this works as expected: The Document Meta Data of the CDM-Root Document is present in the topmost /__meta - Group.

I guess that there is Custom Code that interferes with it.

Thanks, have a good weekend too.

Hi @sven-low-island,
has your question been answered or do you need further support? If it is solved, please, use the checkbox to mark the solution to your problem so that other users also know what helped in your case.
Thanks in advance!
Denise from the Discourse team

Hi @denise-narrow-token

yes, my problem has been resolved: we use currently A12 version 2024.06-ext1. The problem has been solved in 2024.06-ext3. So we should upgrade the A12 version in order to get the fix and use it in our implementation. Thanks!