Skip to main content
May 1, 2024
Question

Save array in rule input

  • May 1, 2024
  • 14 replies
  • 0 views

Hello, 

I have editable grid where I'm trying to save all the selections in rule input after that I will use the rule input to push the data to database. The problem is that I'm not able to save the multi drop down as an array when I select more then one option it save only one and not all in the rule input.

Full code below:

                    rows: a!forEach(
                        items: ri!AOS_Documents_Required,
                        expression: a!gridRowLayout(
                          id: fv!index,
                          contents: {
                            a!dropdownField(
                              choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4",
                                              "Option 5", "Option 6", "Option 7", "Option 8",
                                              "Option 9", "Option 10", "Option 11", "Option 12"},
                              choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
                              label: "Dropdown",
                              labelPosition: "ABOVE",
                              placeholder: "--- Select a Value ---",
                              value: fv!item['recordType!{c80b9de7-a15f-41db-8c92-5cb6b7aa7ce3}AOS_Documents_Required.fields.{cc6533a6-0073-472b-a61d-99d1171e7c3a}Region'],
                              saveInto: fv!item['recordType!{c80b9de7-a15f-41db-8c92-5cb6b7aa7ce3}AOS_Documents_Required.fields.{cc6533a6-0073-472b-a61d-99d1171e7c3a}Region'],
                              searchDisplay: "AUTO",
                              validations: {}
                            ),
                            a!dropdownField(
                              choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4",
                                              "Option 5", "Option 6", "Option 7", "Option 8",
                                              "Option 9", "Option 10", "Option 11", "Option 12"},
                              choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
                              label: "Dropdown",
                              labelPosition: "ABOVE",
                              placeholder: "--- Select a Value ---",
                              value: fv!item['recordType!{c80b9de7-a15f-41db-8c92-5cb6b7aa7ce3}AOS_Documents_Required.fields.{5166be0a-f7de-4498-854d-437c347c4372}Country_Template'],
                              saveInto: fv!item['recordType!{c80b9de7-a15f-41db-8c92-5cb6b7aa7ce3}AOS_Documents_Required.fields.{5166be0a-f7de-4498-854d-437c347c4372}Country_Template'],
                              searchDisplay: "AUTO",
                              validations: {}
                            ),
                            a!multipleDropdownField(
                              choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4",
                                              "Option 5", "Option 6", "Option 7", "Option 8",
                                              "Option 9", "Option 10", "Option 11", "Option 12"},
                              choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
                              label: "Dropdown",
                              labelPosition: "ABOVE",
                              placeholder: "--- Select a Value ---",
                              value: fv!item['recordType!{c80b9de7-a15f-41db-8c92-5cb6b7aa7ce3}AOS_Documents_Required.fields.{2e3c19f3-cbac-4d92-a67d-b7d18703a862}SDS_Language'],
                              saveInto: fv!item['recordType!{c80b9de7-a15f-41db-8c92-5cb6b7aa7ce3}AOS_Documents_Required.fields.{2e3c19f3-cbac-4d92-a67d-b7d18703a862}SDS_Language'],
                              searchDisplay: "AUTO",
                              validations: {}
                            ),
                            a!richTextDisplayField(
                              value: a!richTextIcon(
                                icon: "close",
                                link: a!dynamicLink(
                                saveInto : a!save(
                                  ri!AOS_Documents_Required,
                                  remove(ri!AOS_Documents_Required, fv!index)
                                )
                                ),
                                linkStyle: "STANDALONE",
                                color: "NEGATIVE"
                              )
                            )
                          }
                        )
                      ),
                      selectionSaveInto: {},
                      addRowLink: a!dynamicLink(
                        label: "Add new",
                        saveInto: a!save(
                          ri!AOS_Documents_Required,
                          append(
                            ri!AOS_Documents_Required,
                            'recordType!{c80b9de7-a15f-41db-8c92-5cb6b7aa7ce3}AOS_Documents_Required'()
                          )
                        )
                      ),
                      validations: {},
                      shadeAlternateRows: true

14 replies

mikes0011
Brainy
May 1, 2024

The simple answer is you probably won't be able to save multiple values into a single-value field in a single row of a CDT / RecordType data, depending I suppose on how you have the "SDS_Data" property of your record type configured.

The Expression Guru
May 1, 2024

But it's saving if you use local variables, so I can save multiple values in single multi drop property. I'm using Records and it's setup like this:

mikes0011
Brainy
May 1, 2024
But it's saving if you use local variables

Local variables (depending on what you're trying) can slightly more easily store arrays inside variables inside parent arrays - this is usually not as easy to do with CDT data however.

The Expression Guru