How to autopopulate fields in an interface?

Scenario:Suppose there are 3 fields(A,B,C). Field  A is a custompicker, i want to autopopulate B & C fields on selecting the value in field A. How is it possible,Please help.

Basically, i have created an integration to get details from API, then i am fetching A,B,C fields from the response using expression rule.and then saving them into Datastore using a!writeToDataStore(). Now i want an interface in which if i select value in A field, B& C should autopopulate with the values saved in datastore. or if there is any other approach of getting the value directly from API.

  Discussion posts and replies are publicly visible

Parents
  • I think you can achieve what you are trying to do by using a!refreshVariable() and the parameter "refreshOnVarChange". Here is simple example of what it sounds like you are trying to do:

    a!localVariables(
      local!b: a!refreshVariable(
        value: rule!getValueForB(),
        refreshOnVarChange: ri!a
      ),
      local!c: a!refreshVariable(
        value: rule!getValueForC(),
        refreshOnVarChange: ri!a
      ),
      {
        a!dropdownField(
          label: "a",
          value: ri!a,
          saveInto: ri!a,
          choiceLabels: {1, 2, 3},
          choiceValues: {1, 2, 3}
        ),
        a!textField(
          label: "b",
          value: local!b,
          readOnly: true
        ),
        a!textField(
          label: "c",
          value: local!c,
          readOnly: true
        )
      }
    )

  • Thanks for your reply Alex,

    I am getting the values for b & c already on changing the ri!a part(refresh), But it is not getting saved it in my rule inputs- ri!b or ri!c.

    i have tried saving using a!save(). 

    Everytime it is showing me 'null' in my Rule inputs, but it is getting displayed in my UI.

  • If you want the updated value of the local variable to be saved into a rule input, you would need to configure that save to happen when you submit the form. So for example, you could do this in your submit button to update the latest value to your rule input on submission.

    a!buttonWidget(
      label: "Submit",
      submit: true,
      style: "PRIMARY",
      saveInto: {
        a!save(ri!b, local!b),
        a!save(ri!c, local!c)
      }
    )

Reply
  • If you want the updated value of the local variable to be saved into a rule input, you would need to configure that save to happen when you submit the form. So for example, you could do this in your submit button to update the latest value to your rule input on submission.

    a!buttonWidget(
      label: "Submit",
      submit: true,
      style: "PRIMARY",
      saveInto: {
        a!save(ri!b, local!b),
        a!save(ri!c, local!c)
      }
    )

Children