Hello everyone,
I`m looking for a suitable way to use default values from a form model after saving data (partly) to the backend.
If I´m right the default values from the form model are only used when initializing the model for the first time. After saving data the informations at the form model come exclusively from the backend. That might be the reason why all default values had to be saved in the backend.
With the release 2024.06 there was the new feature of “Not Relevant” as a dependent behavior at a Dependent Group. That feature is pretty interesting for saving only the relevant data to the backend. By using the feature the unrelevant default values won’t be saved to the backend anymore. While that is no problem for data that should be stored permanently, just saving and continue working could lead to an unwanted result. If a unrelevant dependent group becomes relevant, no default values are used.
Is there a way to get the default values from the form model after saving if a unrelevant group of elements becomes relevant?
So there’s a lot to unpack in this thread so I’ll go through it step-by-step.
This is correct. If you model an Initial Value for a Control in the Form Model, this is only considered when creating a new Document.
This is also correct. “Not Relevant” data will not be saved in the backend.
This is where things get a bit unclear. Marking data as “Not Relevant” does not remove it from the frontend. If you are working on a Document and press save, the data in the frontend remains the same. The “Not Relevant” tag simply means that this data is not sent to the backend.
This means that:
if you save and continue working without closing the Form, then you can change a Group from “Not Relevant” → “Relevant” and the data is still there.
if you save, close the Form and then reload the Document, the data is not there as you load the data from the backend and only the “Relevant” data has been persisted.
Yes, there are two ways you can do this and your approach will depend on the use-case that you have. I created some example models for you to look at.
The default data is relevant and should be persisted
The default data should always be set under a specific set of circumstances
If the default data is relevant then you can consider using a Dependent Control to hide the Controls where you have added an initial value. This way you always save the data.
If you need to re-set the default values, consider using Dependent Fields instead of a Dependent Group. You can set the Field to “Not Relevant” for one Trigger state and then set the Value of the Field for the other Trigger state.
We don’t recommend putting too much business logic into the Form Model as:
You can model multiple Form Models so it can be difficult to understand where a particular value came from.
You frontend and backend behavior don’t match.
We’re going to talk about this in the Monthly Modeling Highlight on 27.09.2024. You will be able to view this video shortly after on training.geta12.com and the internal e-Learning platform.
Hi @malcolm-silver-ice,
thanks for your answer and the short example.
Both methods described do not provide a perfect solution for our application. But at least I got a good overview of the possibilities that modeling with A12 offers.
Thanks also for pointing out the monthly highlights.