Load default value in drop-down field and save to record list.

Hello Friends,

I have a user form with 9 fields. One of those fields is a drop-down with two values - Open, Closed. When the user opens the form, I want to drop-down value to default to Open. Then the user can fill out the remaining fields and submit the form.

In screenshot # 1, I made changes to the expression to default to Open as required. But when the user submits the form, the value is not being saved to the record list (Screenshot #2). It's just a blank field in the record list.

Been banging my head on the keyboard and can't figure out this issue. Any help would be greatly appreciated. Thanks!

  Discussion posts and replies are publicly visible

  • There's a few ways to do this, but I always prefer to use local variables to default the value and save into the rule input on submission of the form. You know that they must click the submit button to complete the form, so it's a convenient place to transfer any data from one variable to another. Here's some sample SAIL:

    a!localVariables(
      local!status: "Open",
      a!formLayout(
        contents: {
          a!dropdownField(
            label: "Status",
            choiceLabels: {"Open", "Closed"},
            choiceValues: {"Open", "Closed"},
            value: local!status,
            saveInto: local!status
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: a!buttonWidget(
            label: "Submit",
            style: "PRIMARY",
            submit: true,
            value: local!status,
            saveInto: ri!status
          )
        )
      )
    )

  • Peter,

    Copied below is the change I made according to your code snippet. 

    a!localVariables(
    local!status: "Open",
    a!dropdownField(
    label: "Status",
    choiceLabels: {"Open", "Closed"},
    choiceValues: {"Open", "Closed"},
    value: local!status,
    saveInto: local!status


    One thing I am unsure of is how do I include the saveInto: ri!status portion into the existing code snippet below?


    buttons: a!buttonLayout(
    primaryButtons: {
    if(
    local!creating,
    a!buttonWidgetSubmit(
    label: "Submit Anomaly Record",
    style: "PRIMARY",
    saveInto: {
    a!save(ri!record.createdOn, now()),
    a!save(ri!record.createdBy, loggedInUser()),
    a!save(ri!record.updatedOn, now()),
    a!save(ri!record.updatedBy, loggedInUser()),
    a!save(ri!documents, reject(fn!isnull, ri!documents))

  • 0
    Appian Employee
    in reply to Pauly

    You can add it in as an a!save() as well. So here would be your new save into:

    saveInto: {
      a!save(ri!record.createdOn, now()),
      a!save(ri!record.createdBy, loggedInUser()),
      a!save(ri!record.updatedOn, now()),
      a!save(ri!record.updatedBy, loggedInUser()),
      a!save(ri!documents, reject(fn!isnull, ri!documents)),
      
      /*New save for status */
      a!save(ri!record.status, local!status)
    }

  • Peter,

    I made the code changes you recommended but the status still isn't being saved to the record list. The drop-down field loads "Open" as the default value as intended and the form submit with no expression errors. But when checking the record list, the status value is blank as seen in my screenshot above.

    Some background info....the application I'm working on was created using the Quick Apps Designer. So [by system default] there are two separate files that controls this form - a file which contains the form details and another file which contains the primary button submit expression. I have attached two text files containing the SAIL expression for each file.

    Can you please look them over and see if you can figure out why the status isn't being saved to the record list?

    I have spent the last 5 hours trying to figure this out and I'm just spinning my wheels. I would greatly appreciate any help. Thank you!

    SAIL code for the form field details:

    a!localVariables(
      /* The local variables store the options for the Pick Single / Multiple from List fields    *
       * We only show the active options, plus any inactive options already stored on this record */
      local!statusOptions: a!refreshVariable(
        value: if(ri!record.status.active,rule!LQGAL_RemoveInactiveValues(rule!LQGAL_GetAllStatus(), null),rule!LQGAL_RemoveInactiveValues(rule!LQGAL_GetAllStatus(), ri!record.status.id)),
        /* Ensures this is only calculated on initial load and not each time you update ri!record */
        refreshOnReferencedVarChange: false
      ),
      {
        a!sectionLayout(
          label: ri!label,
          contents: a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!textField(
                    label: "Barcode",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.barcode,
                    saveInto: {ri!record.barcode,
                    if(
                      isnull(ri!record.barcode),
                      {},
                      a!save(
                        ri!record,
                        rule!V16_Transform(rule!V16_EX_GetTireRecord(ri!record.barcode))
    
                      )
    
                    )
    
                    },
                    refreshAfter: "KEYPRESS",
                    required: not(ri!readOnly),
                    readOnly: ri!readOnly,
                    validations: if(
                      len(ri!record.barcode) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.barcode) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Article Number",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.articleNumber,
                    saveInto: ri!record.articleNumber,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.articleNumber) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.articleNumber) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Tire Size",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.tireSize,
                    saveInto: ri!record.tireSize,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.tireSize) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.tireSize) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Curing Press",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.curingPress,
                    saveInto: ri!record.curingPress,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.curingPress) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.curingPress) & " characters."
                    )
                  ),
                  a!paragraphField(
                    label: "Grader Notes",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.graderNotes.value,
                    saveInto: ri!record.graderNotes.value,
                    required: false,
                    readOnly: ri!readOnly,
                    height: "SHORT",
                    validations: if(
                      len(ri!record.graderNotes.value) <= 4000,
                      "",
                      "Value may not be longer than 4000 characters. You have entered " & len(ri!record.graderNotes.value) & " characters."
                    )
                  ),
                  if(
                    ri!creating,
                    {},
                    {
                      a!linkField(
                        label: "Created By",
                        labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                        links: a!userRecordLink(
                          label: rule!LQGAL_FormatName(ri!record.createdBy),
                          user: ri!record.createdBy
                        )
                      ),
                      a!textField(
                        label: "Created On",
                        labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                        value: rule!LQGAL_FriendlyFormatDate(ri!record.createdOn),
                        readOnly: true
                      )
                    }
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!textField(
                    label: "Mold Number",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.moldNumber,
                    saveInto: ri!record.moldNumber,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.moldNumber) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.moldNumber) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Anomaly Code",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.anomalyCode,
                    saveInto: ri!record.anomalyCode,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.anomalyCode) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.anomalyCode) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Green Tire",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.greenTire,
                    saveInto: ri!record.greenTire,
                    required: false,
                    readOnly:or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.greenTire) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.greenTire) & " characters."
                    )
                  ),
                  if(
                    ri!readOnly,
                    a!textField(
                      label: "Status",
                      labelPosition: "ADJACENT",
                      value: ri!record.status.value,
                      readOnly: true
                    ),
                    a!localVariables(
                      local!status: "Open",
                      a!dropdownField(
                        label: "Status",
                        choiceLabels: {"Open", "Closed"},
                        choiceValues: {"Open", "Closed"},
                        value: local!status,
                        saveInto: local!status
                    )
                   )
                  ),
                  if(
                    ri!creating,
                    {},
                    {
                      a!linkField(
                        label: "Updated By",
                        labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                        links: a!userRecordLink(
                          label: rule!LQGAL_FormatName(ri!record.updatedBy),
                          user: ri!record.updatedBy
                        )
                      ),
                      a!textField(
                        label: "Updated On",
                        labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                        value: rule!LQGAL_FriendlyFormatDate(ri!record.updatedOn),
                        readOnly: true
                      )
                    }
                  )
                }
              )
            }
          )
        ),
        a!fileUploadField(
          label: "Anomaly Image",
          maxSelections: 1,
          target: cons!LQGAL_TEMPORARY_DOCUMENTS_FOLDER,
          value: ri!documents,
          saveInto: ri!documents
        )
      }
    )

    SAIL code for the form submit button:

    a!localVariables(
      local!creating: a!refreshVariable(
        value: isnull(ri!record),
        refreshOnReferencedVarChange: false
      ),
      local!oldRecord: a!refreshVariable(
        value: ri!record,
        refreshOnReferencedVarChange: false
      ),
      local!status: a!refreshVariable(
        value: ri!record.status,
        refreshOnReferencedVarChange: true
      ),
      local!oldDocuments: a!refreshVariable(
        value: if(
          isnull(ri!documents),
          {},
          ri!documents
        ),
        refreshOnReferencedVarChange: false
      ),
      a!formLayout(
        label: if(
          local!creating,
          "Add New Anomaly Record",
          "Update Anomaly Record"
        ),
        contents: {
          rule!LQGAL_AnomalyRecordDetails(
            record: ri!record,
            documents: ri!documents,
            deletedDocuments: ri!deletedDocs,
            creating: local!creating,
            readOnly: false
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            if(
              local!creating,
              a!buttonWidgetSubmit(
                label: "Submit Anomaly Record",
                style: "PRIMARY",
                saveInto: {
                  a!save(ri!record.createdOn, now()),
                  a!save(ri!record.createdBy, loggedInUser()),
                  a!save(ri!record.updatedOn, now()),
                  a!save(ri!record.updatedBy, loggedInUser()),
                  a!save(ri!documents, reject(fn!isnull, ri!documents)),
    
                  /*New save for status */
                  a!save(ri!record.status, local!status)
                }
              ),
              a!buttonWidgetSubmit(
                label: "Update Anomaly Record",
                style: "PRIMARY",
                saveInto: {
                  a!save(ri!record.updatedOn, now()),
                  a!save(ri!record.updatedBy, loggedInUser()),
                  a!save(ri!oldRecord, local!oldRecord),
                  a!save(ri!documents, reject(fn!isnull, ri!documents)),
                  a!save(ri!addedDocs, reject(fn!isnull, difference(ri!documents, local!oldDocuments))),
                  a!save(ri!oldDocs, local!oldDocuments)
                }
              )
            )
          },
          secondaryButtons: {
            if(
              local!creating,
              {},
              a!buttonWidgetSubmit(
                label: "Cancel",
                style: "NORMAL",
                value: true,
                saveInto: {
                  ri!cancel,
                  a!save(ri!addedDocs, reject(fn!isnull, difference(ri!documents, local!oldDocuments))),
                  a!save(ri!deletedDocs, append(difference(ri!deletedDocs, local!oldDocuments), ri!addedDocs))
                },
                skipValidation: true
              )
            )
          }
        )
      )
    )

  • Peter,

    I made the changes you suggested. The drop-down field defaults to the "Open" status value as intended and the form submits with no errors. But the status still isn't being saved to the record list. Can you please looks over the SAIL code and see if you can see what I may be overlooking? Thanks.

    a!localVariables(
      /* The local variables store the options for the Pick Single / Multiple from List fields    *
       * We only show the active options, plus any inactive options already stored on this record */
      local!statusOptions: a!refreshVariable(
        value: if(ri!record.status.active,rule!LQGAL_RemoveInactiveValues(rule!LQGAL_GetAllStatus(), null),rule!LQGAL_RemoveInactiveValues(rule!LQGAL_GetAllStatus(), ri!record.status.id)),
        /* Ensures this is only calculated on initial load and not each time you update ri!record */
        refreshOnReferencedVarChange: false
      ),
      {
        a!sectionLayout(
          label: ri!label,
          contents: a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!textField(
                    label: "Barcode",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.barcode,
                    saveInto: {ri!record.barcode,
                    if(
                      isnull(ri!record.barcode),
                      {},
                      a!save(
                        ri!record,
                        rule!V16_Transform(rule!V16_EX_GetTireRecord(ri!record.barcode))
    
                      )
    
                    )
    
                    },
                    refreshAfter: "KEYPRESS",
                    required: not(ri!readOnly),
                    readOnly: ri!readOnly,
                    validations: if(
                      len(ri!record.barcode) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.barcode) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Article Number",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.articleNumber,
                    saveInto: ri!record.articleNumber,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.articleNumber) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.articleNumber) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Tire Size",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.tireSize,
                    saveInto: ri!record.tireSize,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.tireSize) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.tireSize) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Curing Press",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.curingPress,
                    saveInto: ri!record.curingPress,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.curingPress) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.curingPress) & " characters."
                    )
                  ),
                  a!paragraphField(
                    label: "Grader Notes",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.graderNotes.value,
                    saveInto: ri!record.graderNotes.value,
                    required: false,
                    readOnly: ri!readOnly,
                    height: "SHORT",
                    validations: if(
                      len(ri!record.graderNotes.value) <= 4000,
                      "",
                      "Value may not be longer than 4000 characters. You have entered " & len(ri!record.graderNotes.value) & " characters."
                    )
                  ),
                  if(
                    ri!creating,
                    {},
                    {
                      a!linkField(
                        label: "Created By",
                        labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                        links: a!userRecordLink(
                          label: rule!LQGAL_FormatName(ri!record.createdBy),
                          user: ri!record.createdBy
                        )
                      ),
                      a!textField(
                        label: "Created On",
                        labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                        value: rule!LQGAL_FriendlyFormatDate(ri!record.createdOn),
                        readOnly: true
                      )
                    }
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!textField(
                    label: "Mold Number",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.moldNumber,
                    saveInto: ri!record.moldNumber,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.moldNumber) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.moldNumber) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Anomaly Code",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.anomalyCode,
                    saveInto: ri!record.anomalyCode,
                    required: false,
                    readOnly: or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.anomalyCode) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.anomalyCode) & " characters."
                    )
                  ),
                  a!textField(
                    label: "Green Tire",
                    labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                    instructions: if(ri!readOnly, "", ""),
                    helpTooltip: if(ri!readOnly, "", ""),
                    placeholder: if(ri!readOnly, "", ""),
                    value: ri!record.greenTire,
                    saveInto: ri!record.greenTire,
                    required: false,
                    readOnly:or(
                      ri!readOnly,  
                      ri!automatic
                    ),
                    validations: if(
                      len(ri!record.greenTire) <= 200,
                      "",
                      "Value may not be longer than 200 characters. You have entered " & len(ri!record.greenTire) & " characters."
                    )
                  ),
                  if(
                    ri!readOnly,
                    a!textField(
                      label: "Status",
                      labelPosition: "ADJACENT",
                      value: ri!record.status.value,
                      readOnly: true
                    ),
                    a!localVariables(
                      local!status: "Open",
                      a!dropdownField(
                        label: "Status",
                        choiceLabels: {"Open", "Closed"},
                        choiceValues: {"Open", "Closed"},
                        value: local!status,
                        saveInto: local!status
                    )
                   )
                  ),
                  if(
                    ri!creating,
                    {},
                    {
                      a!linkField(
                        label: "Updated By",
                        labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                        links: a!userRecordLink(
                          label: rule!LQGAL_FormatName(ri!record.updatedBy),
                          user: ri!record.updatedBy
                        )
                      ),
                      a!textField(
                        label: "Updated On",
                        labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"),
                        value: rule!LQGAL_FriendlyFormatDate(ri!record.updatedOn),
                        readOnly: true
                      )
                    }
                  )
                }
              )
            }
          )
        ),
        a!fileUploadField(
          label: "Anomaly Image",
          maxSelections: 1,
          target: cons!LQGAL_TEMPORARY_DOCUMENTS_FOLDER,
          value: ri!documents,
          saveInto: ri!documents
        )
      }
    )

    a!localVariables(
      local!creating: a!refreshVariable(
        value: isnull(ri!record),
        refreshOnReferencedVarChange: false
      ),
      local!oldRecord: a!refreshVariable(
        value: ri!record,
        refreshOnReferencedVarChange: false
      ),
      local!status: a!refreshVariable(
        value: ri!record.status,
        refreshOnReferencedVarChange: true
      ),
      local!oldDocuments: a!refreshVariable(
        value: if(
          isnull(ri!documents),
          {},
          ri!documents
        ),
        refreshOnReferencedVarChange: false
      ),
      a!formLayout(
        label: if(
          local!creating,
          "Add New Anomaly Record",
          "Update Anomaly Record"
        ),
        contents: {
          rule!LQGAL_AnomalyRecordDetails(
            record: ri!record,
            documents: ri!documents,
            deletedDocuments: ri!deletedDocs,
            creating: local!creating,
            readOnly: false
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            if(
              local!creating,
              a!buttonWidgetSubmit(
                label: "Submit Anomaly Record",
                style: "PRIMARY",
                saveInto: {
                  a!save(ri!record.createdOn, now()),
                  a!save(ri!record.createdBy, loggedInUser()),
                  a!save(ri!record.updatedOn, now()),
                  a!save(ri!record.updatedBy, loggedInUser()),
                  a!save(ri!documents, reject(fn!isnull, ri!documents)),
    
                  /*New save for status */
                  a!save(ri!record.status, local!status)
                }
              ),
              a!buttonWidgetSubmit(
                label: "Update Anomaly Record",
                style: "PRIMARY",
                saveInto: {
                  a!save(ri!record.updatedOn, now()),
                  a!save(ri!record.updatedBy, loggedInUser()),
                  a!save(ri!oldRecord, local!oldRecord),
                  a!save(ri!documents, reject(fn!isnull, ri!documents)),
                  a!save(ri!addedDocs, reject(fn!isnull, difference(ri!documents, local!oldDocuments))),
                  a!save(ri!oldDocs, local!oldDocuments)
                }
              )
            )
          },
          secondaryButtons: {
            if(
              local!creating,
              {},
              a!buttonWidgetSubmit(
                label: "Cancel",
                style: "NORMAL",
                value: true,
                saveInto: {
                  ri!cancel,
                  a!save(ri!addedDocs, reject(fn!isnull, difference(ri!documents, local!oldDocuments))),
                  a!save(ri!deletedDocs, append(difference(ri!deletedDocs, local!oldDocuments), ri!addedDocs))
                },
                skipValidation: true
              )
            )
          }
        )
      )
    )

  • 0
    Certified Lead Developer
    in reply to Pauly

    In your second code box, you aren't setting local!status to any default value (i.e. "Open") as Peter's original code suggestion entailed.  Therefore when the user clicks "Submit Anomaly Record" without having made any changes, I would expect it to still save the empty value into ri!record.status.

    Just to take a guess here, you probably want your variable defintion for local!status to check if ri!record.status is null, and if so, set the variable to "Open", and if not, retain its current non-null value.

    Also: how are the two above interfaces being called?  I don't see how the interface with the dropdown is actually expecting to change the value of local!status in the parent interface.  This might change the overall answer as well.  The section with the dropdown seems to be defining its own local!status variable which then of course isn't used for anything else.  My guess is that you'll need to add a ri!status input to the lower rule and pass in local!status from the parent rule.

  • Ah, in that case it's probably easiest to make the update in the top level interface only. The nice thing about this is there is already a local variable in the second interface you provided that sets a value for local!record. You should be able to update your interface to define a default variable for status like this:

    a!localVariables(
      local!creating: a!refreshVariable(
        value: isnull(ri!record),
        refreshOnReferencedVarChange: false
      ),
      local!oldRecord: a!refreshVariable(
        value: {
          id: ri!record.id,
          name: ri!record.name,
          status: if(
            isnull(ri!record.status),
            "Open",
            ri!record.status
          ),
          type: ri!record.type
          /* Add your other fields below here in a similar manner */
        },
        refreshOnReferencedVarChange: false
      ),
      ...

    Basically you will define the default values for each of the fields in ri!record. For all of your values except for the status, the value you want to use is the same as the data from the record. For status, you will use "Open".

    It's a little tedious, but it's easier to set this up at the parent level. Then, it should work correctly with your other interface too.

    Let me know if that works or if you have other questions!