Here's what I think you're trying to achieve:
- You want the form user to select a beneficiary
- You want to show some known data about that beneficiary and you want to allow the form user to edit that known data. In other words, you want a dynamic default that will maintain the user-provided value if the default is overwritten
- You want those dynamic defaults to update if the chosen beneficiary changes (which is why you don't want to use
once
) - You want all entered data to stay if the beneficiary is deleted from the attached data file
With these assumptions, I've modified your example to fam_code.xlsx (14.0 KB)
One really important thing to note first is that you want to make sure not to have fields that are user-editable and have calculation
s on them. If you do that, the user-provided value will always be overwritten by the calculation. If you want a dynamic default, you need to either use the default
column or the trigger
column to make sure the calculations are only run when it's appropriate to replace the current value. You can learn more in the docs about defaults.
In this case, I think you want your dynamic defaults to be triggered on a change in ${host_code}
and you want the default expression to be something like if (${B_ID} != '', pulldata('detail_csv', 'Name', 'Beneficiary_ID', ${B_ID}), .)
. This means that if there was a match for the beneficiary ID in the CSV, the corresponding value in the CSV should be used. But if there's no match, then the user-provided value or the default from when the form was previously filled should be kept. That's what the .
means. Because the expression is used with a trigger, it gets around the limitation on self-references that I described above.
You'll see that unfortunately this doesn't work in the repeat. I haven't had a chance to look into that any more deeply but I did want to share some initial ideas in case you found them helpful.