Conditionally Autofilling Text Field

Certified Associate Developer

I'm trying to conditionally autofill a text field based on two other text fields above it. I've gotten the value in the text field to display correctly however the value doesn't save into the variable set in the "saveInto" property. I've tried changing the "refreshAfter" property and using local variables with the "a!refreshVariable" function with both the "refreshOnVarChange" and "refreshAlways" options. I've also tried the "a!save" function both inside and outside of the if statement.

Does anyone have any suggestions on how I could do this or know where my problem is? I'm pretty new to Appian so I may be going about this completely wrong.

a!textField(
                    local!SealModel: a!refreshVariable(refreshAlways: true()
                      /*refreshOnVarChange: {*/
                        /*local!SealManuf,*/
                        /*local!SealPartNum,*/
                        /*local!SealModel*/
                      /*}*/
                    ),
                    label: "Seal Model/Type:",
                    labelPosition: "ABOVE",
                    value: if(
                      and(
                        local!SealManuf = "XYZ",
                        not(isnull(local!SealPartNum))
                      ),
                      mid(local!SealPartNum, 8, 3),
                      local!SealModel
                    ),
                    /*a!save(local!SealModel, mid(local!SealPartNum, 8, 3)),*/
                    saveInto: local!SealModel,
                    refreshAfter: "UNFOCUS",
                    /*disabled: if(and(ri!SealManuf = "XYZ", not(isnull(ri!SealPartNum))),*/
                    /*true(), false()),*/
                    validations: {}
                  ),

  Discussion posts and replies are publicly visible

Parents
  • Hi Jack, note an input field will only call it's saveInto parameter if it is interacted with by the user (this is where all of your a!save's must reside).  If you are using this field for display only it will not update any values itself, due to no user interaction.

    Typical designs in this scenario include utilizing the saveInto on your editable text fields above to also populate this third variable, or utilizing saveInto within the submit button, so the local! value can be persisted out when the form is being exited.  For example, the Submit button would mimic the logic in your read-only text field as:

    a!buttonWidget(
      label: "Submit",
      value: false,
      saveInto: {
        ri!cancel,
        a!save(
          ri!whereYouWantYourDataToGo,
          if(
            and(
              local!SealManuf = "XYZ",
              not(isnull(local!SealPartNum))
            ),
            mid(local!SealPartNum, 8, 3),
            local!SealModel
          )
        )
      }
    )

Reply
  • Hi Jack, note an input field will only call it's saveInto parameter if it is interacted with by the user (this is where all of your a!save's must reside).  If you are using this field for display only it will not update any values itself, due to no user interaction.

    Typical designs in this scenario include utilizing the saveInto on your editable text fields above to also populate this third variable, or utilizing saveInto within the submit button, so the local! value can be persisted out when the form is being exited.  For example, the Submit button would mimic the logic in your read-only text field as:

    a!buttonWidget(
      label: "Submit",
      value: false,
      saveInto: {
        ri!cancel,
        a!save(
          ri!whereYouWantYourDataToGo,
          if(
            and(
              local!SealManuf = "XYZ",
              not(isnull(local!SealPartNum))
            ),
            mid(local!SealPartNum, 8, 3),
            local!SealModel
          )
        )
      }
    )

Children