Unable to save local variable to rule input

a!localVariables(

  local!doctorsList:rule!HM_getDoctor(department: ri!requestedDept),

  a!columnsLayout(

    columns: {

      a!columnLayout(

        contents: {

          a!sectionLayout(

            label: "Appointment",

            contents: {

              a!dropdownField(

                label: "Department",

                labelPosition: "ABOVE",

                placeholder: "--- Select a Value ---",

                choiceLabels:{"Gynecologist","Pediatrician","Psychiatrist","General Surgeon","Cardiac Surgeon"},

                choiceValues:{"Gynecologist","Pediatrician","Psychiatrist","General Surgeon","Cardiac Surgeon"},

                value:ri!requestedDept,

                saveInto: {ri!requestedDept},

                searchDisplay: "AUTO",

                validations: {}

              )

            }

          ),

          a!sectionLayout(

            label: "List of Doctors",

            contents: {

              a!columnsLayout(

                columns: {

                  a!columnLayout(

                    contents: {

                      a!textField(

                        label: "Doctor Name",

                        labelPosition: "ADJACENT",

                        value: local!doctorsList.doctorName,

                        saveInto: ri!docName,

                        readOnly: true()

                      ),

                      a!textField(

                        label: "Doctor Dept",

                        labelPosition: "ADJACENT",

                        value: local!doctorsList.doctorDept,

                        saveInto: ri!docDept,

                        readOnly: true()

                      ),

                      a!dateField(

                        label: "Doctor Visit",

                        labelPosition: "ADJACENT",

                        value: local!doctorsList.doctorVisit,

                        saveInto: ri!docVisit,

                        readOnly: true()

                      )

                    }

                  )

                }

              )

            }

          ),

          a!sectionLayout(

            label: "",

            contents: {

              a!columnsLayout(

                columns: {

                  a!columnLayout(

                    contents: {

                      a!buttonArrayLayout(

                        buttons: {

                          a!buttonWidget(

                            label: "Cancel",

                            value: true,

                            saveInto: ri!cancel,

                            submit: true,

                            style: "NORMAL",

                            validate: false

                          )

                        },

                        align: "START"

                      )

                    }

                  ),

                  a!columnLayout(

                    contents: {

                      a!buttonArrayLayout(

                        buttons: {

                          a!buttonWidget(

                            label: "Submit",

                            submit: true,

                            style: "PRIMARY"

                          )

                        },

                        align: "END"

                      )

                    }

                  )

                }

              )

            }

          )

        }

      )

    }

  )

)

I am trying to save local!doctorsList.doctorName to ri!docName, local!doctorsList.doctor.doctorDept to ri!docDept and local!doctorsList.doctorVisit to ri!docVisit. However nothing is being saved into the rule inputs. I am able to display the value of the local variables so i'm assuming there is some problem with the way i'm trying to assign the value to the rule inputs. Any help is deeply appreciated.

  Discussion posts and replies are publicly visible

  • Hi ,

    The fact that you are able to display the values in the field does not automatically save it in your rule inputs, so your save into option in your read only text fields will not help. In your scenario, you should add a save into in your submit button.

    As I did not have the results of your query, I changed a little your code in order to create an example. As the label was called list, but the way how you were displaying was single item I also changed that. I changed the rule inputs to array and also have added a new rule input type MAP. 

    It is not a final solution but will give you some ideas, please refer to the code below:

    a!localVariables(
      local!dept: {
        "Gynecologist",
        "Pediatrician",
        "Psychiatrist",
        "General Surgeon",
        "Cardiac Surgeon"
      },
      local!doctorsFullList: {
        a!map(
          doctorDept: "Gynecologist",
          doctorName: "Gynecologist 1",
          doctorVisit: todate(today())
        ),
        a!map(
          doctorDept: "Gynecologist",
          doctorName: "Gynecologist 2",
          doctorVisit: todate(today() - 2)
        ),
        a!map(
          doctorDept: "Gynecologist",
          doctorName: "Gynecologist 3",
          doctorVisit: todate(today() - 3)
        ),
        a!map(
          doctorDept: "Pediatrician",
          doctorName: "Pediatrician 1",
          doctorVisit: todate(today())
        ),
        a!map(
          doctorDept: "Pediatrician",
          doctorName: "Pediatrician 2",
          doctorVisit: todate(today() - 2)
        ),
        a!map(
          doctorDept: "Psychiatrist",
          doctorName: "Psychiatrist 1",
          doctorVisit: todate(today())
        ),
        a!map(
          doctorDept: "General Surgeon",
          doctorName: "General Surgeon 1",
          doctorVisit: todate(today())
        ),
        a!map(
          doctorDept: "General Surgeon",
          doctorName: "General Surgeon 2",
          doctorVisit: todate(today() - 2)
        ),
        a!map(
          doctorDept: "Cardiac Surgeon",
          doctorName: "Cardiac Surgeon 1",
          doctorVisit: todate(today())
        ),
        a!map(
          doctorDept: "Cardiac Surgeon",
          doctorName: "Cardiac Surgeon 2",
          doctorVisit: todate(today() - 2)
        ),
        a!map(
          doctorDept: "Cardiac Surgeon",
          doctorName: "Cardiac Surgeon 3",
          doctorVisit: todate(today() - 3)
        ),
        a!map(
          doctorDept: "Cardiac Surgeon",
          doctorName: "Cardiac Surgeon 4",
          doctorVisit: todate(today() - 4)
        ),
        
      },
      local!doctorsList: a!refreshVariable(
        value: index(
          local!doctorsFullList,
          wherecontains(
            ri!requestedDept,
            local!doctorsFullList.doctorDept
          ),
          null
        ),
        refreshOnReferencedVarChange: true()
      ),
      {
        a!sectionLayout(
          label: "Appointment",
          contents: {
            a!dropdownField(
              label: "Department",
              labelPosition: "ABOVE",
              placeholder: "--- Select a Value ---",
              choiceLabels: local!dept,
              choiceValues: local!dept,
              value: ri!requestedDept,
              saveInto: { ri!requestedDept },
              searchDisplay: "AUTO",
              validations: {}
            )
          }
        ),
        a!richTextDisplayField(labelPosition: "COLLAPSED"),
        a!sectionLayout(
          label: "List of Doctors",
          contents: {
            if(
              length(local!doctorsList) = 0,
              a!richTextDisplayField(
                labelPosition: "COLLAPSED",
                align: "LEFT",
                value: a!richTextItem(
                  size: "MEDIUM",
                  color: "ACCENT",
                  text: "No data selected",
                  style: "EMPHASIS"
                )
              ),
              a!columnsLayout(
                columns: {
                  a!forEach(
                    items: local!doctorsList,
                    expression: {
                      a!columnLayout(
                        a!cardLayout(
                          contents: {
                            a!textField(
                              label: "Doctor Name:",
                              labelPosition: "ADJACENT",
                              value: fv!item.doctorName,
                              readOnly: true()
                            ),
                            a!textField(
                              label: "Doctor Dept:",
                              labelPosition: "ADJACENT",
                              value: fv!item.doctorDept,
                              readOnly: true()
                            ),
                            a!dateField(
                              label: "Doctor Visit:",
                              labelPosition: "ADJACENT",
                              value: fv!item.doctorVisit,
                              readOnly: true()
                            )
                          }
                        )
                      )
                    }
                  )
                }
              )
            )
          }
        ),
        a!richTextDisplayField(labelPosition: "COLLAPSED"),
        a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Submit",
              submit: true,
              style: "PRIMARY",
              saveInto: {
                a!save(ri!docName, index(local!doctorsList,"doctorName",null)),
                a!save(ri!docDept, index(local!doctorsList,"doctorDept",null)),
                a!save(ri!docVisit, index(local!doctorsList,"doctorVisit",null)),
                a!save(ri!selectedDoctors,local!doctorsList)
              }
            )
          },
          secondaryButtons: {
            a!buttonWidget(
              label: "Cancel",
              value: true,
              saveInto: ri!cancel,
              submit: true,
              style: "NORMAL",
              validate: false
            )
          }
        )
      }
    )

    I hope that helps you.

    Regards

    Acacio B