Skip to main content
carsonw
Participating Frequently
March 31, 2021
Solved

I'd like to store the values of a multipledropdownfield into the a dynamically sized CDT's rule input.

  • March 31, 2021
  • 2 replies
  • 0 views

Hello,

I'd like to store the values of a multiple dropdownfield into the fields of an cdt.  So for example, I'd like to make something like the following work:

a!multipleDropdownField(
label: "Category",
placeholder: "Select Category",
choiceLabels: index(local!categoryRefData,"value",{}),
choiceValues: index(local!categoryRefData,"id",{}),
value: index(ri!ctgry, "ctgryId", {}),
saveInto: ri!ctgry.ctgryId
)

How can this be done?

Thanks!

Best answer by mikes0011

If you're relatively sure the "categoryRefData" values will never change, the easiest solution is to make the choiceValues just the local!categoryRefData array, instead of pulling the "id" property from it.  For your value and saveInto parameters, you'd just point it towards ri!ctgry.

The danger with this approach is that if you're ever in a position where you want to load a form with pre-selected values but any of the category data has changed, the dropdown will sense a mismatch and throw an error.  That's why I avoid assembling a CDT array like this straight from the dropdown, and instead save a basic id array and then, if needed, assemble a CDT array either at form submit or subsequently within the process.

2 replies

mikes0011
mikes0011Answer
Brainy
March 31, 2021

If you're relatively sure the "categoryRefData" values will never change, the easiest solution is to make the choiceValues just the local!categoryRefData array, instead of pulling the "id" property from it.  For your value and saveInto parameters, you'd just point it towards ri!ctgry.

The danger with this approach is that if you're ever in a position where you want to load a form with pre-selected values but any of the category data has changed, the dropdown will sense a mismatch and throw an error.  That's why I avoid assembling a CDT array like this straight from the dropdown, and instead save a basic id array and then, if needed, assemble a CDT array either at form submit or subsequently within the process.

The Expression Guru
carsonw
carsonwAuthor
Participating Frequently
March 31, 2021

Thank you!  This answer was very helpful.