Skip to main content
July 28, 2021
Solved

Why wont this save?

  • July 28, 2021
  • 5 replies
  • 0 views

Hi,

So Im trying to get this code to save below into my ri! field but no matter what I do it will not save. Can someone please tell me whats wrong here?

    Best answer by gayathris111098

    Hi

    Below sample may be helpful for this case,

    a!localVariables(
      local!firstItem_txt,
      local!secondItem_txt,
      local!thirItem_txt,
      local!combinedItem_txt,/*ri!orders.products*/
      {
        a!sectionLayout(
          label: "Section",
          contents: {
            a!columnsLayout(
              columns: {
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: "Dropdown 1",
                      labelPosition: "ABOVE",
                      placeholder: "--- Select a Value ---",
                      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: {
                        "Option 1",
                        "Option 2",
                        "Option 3",
                        "Option 4",
                        "Option 5",
                        "Option 6",
                        "Option 7",
                        "Option 8",
                        "Option 9",
                        "Option 10",
                        "Option 11",
                        "Option 12"
                      },
                      value: local!firstItem_txt,
                      saveInto: {
                        local!firstItem_txt,
                        if(
                          or(
                            isnull(local!firstItem_txt),
                            isnull(local!secondItem_txt),
                            isnull(local!thirItem_txt)
                          ),
                          {},
                          a!save(
                            local!combinedItem_txt,
                            joinarray(
                              {
                                local!firstItem_txt,
                                local!secondItem_txt,
                                local!thirItem_txt
                              },
                              ","
                            )
                          )
                        )
                      }
                    )
                  }
                ),
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: "Dropdown 2",
                      labelPosition: "ABOVE",
                      placeholder: "--- Select a Value ---",
                      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: {
                        "Option 1",
                        "Option 2",
                        "Option 3",
                        "Option 4",
                        "Option 5",
                        "Option 6",
                        "Option 7",
                        "Option 8",
                        "Option 9",
                        "Option 10",
                        "Option 11",
                        "Option 12"
                      },
                      value: local!secondItem_txt,
                      saveInto: {
                        local!secondItem_txt,
                        if(
                          or(
                            isnull(local!firstItem_txt),
                            isnull(local!secondItem_txt),
                            isnull(local!thirItem_txt)
                          ),
                          {},
                          a!save(
                            local!combinedItem_txt,
                            joinarray(
                              {
                                local!firstItem_txt,
                                local!secondItem_txt,
                                local!thirItem_txt
                              },
                              ","
                            )
                          )
                        )
                      }
                    )
                  }
                ),
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: "Dropdown 3",
                      labelPosition: "ABOVE",
                      placeholder: "--- Select a Value ---",
                      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: {
                        "Option 1",
                        "Option 2",
                        "Option 3",
                        "Option 4",
                        "Option 5",
                        "Option 6",
                        "Option 7",
                        "Option 8",
                        "Option 9",
                        "Option 10",
                        "Option 11",
                        "Option 12"
                      },
                      value: local!thirItem_txt,
                      saveInto: {
                        local!thirItem_txt,
                        if(
                          or(
                            isnull(local!firstItem_txt),
                            isnull(local!secondItem_txt),
                            isnull(local!thirItem_txt)
                          ),
                          {},
                          a!save(
                            local!combinedItem_txt,
                            joinarray(
                              {
                                local!firstItem_txt,
                                local!secondItem_txt,
                                local!thirItem_txt
                              },
                              ","
                            )
                          )
                        )
                      }
                    )
                  }
                )
              }
            )
          }
        ),
        a!textField(
          showWhen: not(isnull(local!combinedItem_txt)),
          label: "Result",
          labelPosition: "ABOVE",
          readOnly: true,
          value: local!combinedItem_txt
        )
      }
    )

    5 replies

    gayathris111098
    July 28, 2021

    Hi

    The expression in the saveInto parameter only evaluates when the user interacts with the component. Since you have made it as readOnly there is no user interaction hence so value is not populating. 

    Can you explain your usecase?

    gayathris111098
    July 28, 2021

    If you want just populate this for DB writes, you can call it in the submit button saveInto like

    saveInto:{

    a!save(

    ri!orders.products, concat(

    ri!firstItem

    )

    )

    }

    July 28, 2021

    Why do it there?