Dear all,
I have an issue saving an optional record in a form. The form displays a list of records from a /Books/ table. Each /Book/ record may have one or more translations. On the form, users have the possibility to enter the default translation (set to the system language, i.e., en-US).
Data model:
/Book/ is the main data source on the form; /BookTranslation/ is the optional data source. It is joined with an outer join to the /Book/ data source. The init() method has been overridden on the /BookTranslation/ data source, to ensure only 1 record is selected.
When I try to save a record, the /Book/ field on the /BookTranslation/ data source is left blank, causing the save operation to fail.
The form has /Data Source Change Group/ set to /None/, which apparently causes this behavior. Changing this property to /ImplicitInnerOuter/ would solve the issue, but, unfortunately, this is not a viable solution, as the actual scenario is an extension of a standard form (this is a simplified example).
I have tried to override the
write() method on the data sources, but this did not help. As per
documentation, I was expecting that each data source got saved in its own transaction, following the method call sequence below:
- Book.validateWrite()
- Book.write()
- BookTranslation.validateWrite()
- BookTranslation.write()
Adding code to the Book.write() method would allow me to set up the needed values in the /BookTranslation/ record. However, the methods are actually called in the following order:
- Book.validateWrite()
- BookTranslation.validateWrite()
- Book.write()
- BookTranslation.write()
This would require to perform this initialization in the validateWrite() method, which seems the wrong place to me. Additionally, since validateWrite() is called before write(), i.e., before the record is saved to the database, I do not have the possibility to read the Book's /RecId/ (in the actual scenario, /BookTranslation/ is linked to /Book/ via RecId, not via ISBN).
Does anybody have suggestions on how to solve this issue? I would be grateful for your feedback.
Best regards,
Daniel