Is it possible to set a value of an DM field for all existing repetitions by using a control in the FM just once?

Hi,
I would like to set (or change) the value of an repeatable DM field.
While I have no problem to make it work if the user sets the value of the DM field for each repeated line (nested) manually, I found no solution if I want to set it for all existing repeats with just one user action.
Here is a short example:
There is a bookcase with lets say 5 books in it. The books-group is a repetition inside die bookcase-group of the DM.
One of the the fields for “books” is “owner”.
I`m looking for a way to set the same value of “owner” for all 5 books with just one user-action.
Placing the Control outside its nested repeatable group and using the Control Index doesn’t seem to work.
Are there any ideas?

Hi @bjoern-sharp-oak,

We have various different modeling options to set a value

  1. Model a Computation rule in the Docuemtn Model - this will cause the control to be read only and the value can only be one of the values in the computations
  2. Use an initial value for the control in the Form Model - you can edit this but not dynamically set this value
  3. Use a dependency in the Form Model to dynamically set the value.

This third option sounds like the closest to your use case. You can model this as follows:

  1. Model a field with your different ownership options outside the repeatable group in the Document Model. This needs to be an enumeration field as this will be the trigger field for your dependency.
  2. Switch to the Form Model and navigate to the “data configuration” tab.
  3. Navigate to the field in your repeatable group where the ownership is stored. Please note, this should be a copy of the field in step 1. You cannot mix and match data types.
  4. Click on this field and select dependent field.
  5. Select the field that you modeled in step1 as the trigger field.
  6. Select each of the values of the field that you modeled and set “Display” = “Default”, “Value” = “Field Value”. Then select the field from step1 in the drop-down menu next to this.

Each time that you make a selection in the enumeration, this value will now be written into all rows in the repeat. This will overwrite any data already in the fields.

I’ve added simple models (2023.06) to show this.
Books_DM.json (4.9 KB)
Books_FM.json (4.3 KB)

Thanks @malcolm-silver-ice,
With your solution I was able to make it work, even if I was hoping for a more elegant way to do so.
In my understandig the solution 3 means I have to copy (and as time goes on to keep them both in sync) the affected fields in die DM. If the field is i.e. a date or string I have to use an aditional transient auxiliary field of the type “boolean” with a computation rule, to have the trigger mentioned in your step 5. Because it`s more than just one affected field that feels a little cumbersome.
With an elegant way I was looking for something like the “Control Index” but not just for one specific repeatable but for all existing repeated lines.
Anyway I got a solution, so thanks for that.

You’re right that adding new books to the repeat after the trigger field has been set to a certain value will lead to books without an owner.

This is because the dependent values only update when we change the value of the trigger field.

I suggested this option so that you can edit these values after they have been set. If you are happy to set all owners to be the same value, use a computation (solution 1). This will update as each new row is added.

Unfortunately, it’s not clear to me if you want to:

  • Set all books to have the same owner (Solution 1, this will auto update)
  • Set all books to have the same owner and then manually change them later (Solution 3, this will not auto update but de-selecting the value and reselecting it will set all onwers)

Finally, if you want to use solution 3 with strings or dates, you can have an update trigger for the dependency which is a boolean, confirm or enumeration. You can take the field value from any field you like, as long as the data types match. If you want to write a date to a date field in the repeat using a dependency, you can do this too.

I want to change the owner later (manually), so solution 3 is what seems to be the best option.
Thanks for the further informations.