Can we save the rules or values in with()?

a

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi tirumalar0001 Adding few points to the above comments.

    Yes it's true that you can refresh a variable(defined inside load, as a rule input or a node input) by the use of with() on each user interaction/evaluation (in fact the same can be achieved by using load as well) but you cannot use a!save() / saveInto referencing to a local variable which is defined inside with() as this will break your interface saying:

    Interface Definition: Expression evaluation error: An error occurred while executing a save: Expression evaluation error: The save target is a with() variable. The save target must be a load() variable, process variable, or node input (or a rule input passed one of those three). with() variables are reinitialized with each evaluation and therefore cannot be used as save targets.

    You can re-evaluate / update / insert / delete the value of a rule input / local variable defined under load() but you cannot do the same when a variable is defined inside with() as they are tend to re-initialized upon each user interaction/evaluation as shown in below code snippet:

    /* Here saveInto will cause to break your Interface because the variable is defined within with() and being used at saveInto */
    with(
      local!firstName_txt,
      a!formLayout(
        label: "With Component Demo",
        contents: {
          a!textField(
            label: "First Name",
            required: true(),
            value: local!firstName_txt,
            saveInto: local!firstName_txt /*This will cause this issue */
          )
        },
        buttons: {
          a!buttonLayout(
            primaryButtons: {
              a!buttonWidgetSubmit(
                label: "SUBMIT",
                style: "PRIMARY"
              )
            }
          )
        }
      )
    )

    Hope this will help you.

Reply
  • 0
    Certified Lead Developer

    Hi tirumalar0001 Adding few points to the above comments.

    Yes it's true that you can refresh a variable(defined inside load, as a rule input or a node input) by the use of with() on each user interaction/evaluation (in fact the same can be achieved by using load as well) but you cannot use a!save() / saveInto referencing to a local variable which is defined inside with() as this will break your interface saying:

    Interface Definition: Expression evaluation error: An error occurred while executing a save: Expression evaluation error: The save target is a with() variable. The save target must be a load() variable, process variable, or node input (or a rule input passed one of those three). with() variables are reinitialized with each evaluation and therefore cannot be used as save targets.

    You can re-evaluate / update / insert / delete the value of a rule input / local variable defined under load() but you cannot do the same when a variable is defined inside with() as they are tend to re-initialized upon each user interaction/evaluation as shown in below code snippet:

    /* Here saveInto will cause to break your Interface because the variable is defined within with() and being used at saveInto */
    with(
      local!firstName_txt,
      a!formLayout(
        label: "With Component Demo",
        contents: {
          a!textField(
            label: "First Name",
            required: true(),
            value: local!firstName_txt,
            saveInto: local!firstName_txt /*This will cause this issue */
          )
        },
        buttons: {
          a!buttonLayout(
            primaryButtons: {
              a!buttonWidgetSubmit(
                label: "SUBMIT",
                style: "PRIMARY"
              )
            }
          )
        }
      )
    )

    Hope this will help you.

Children
No Data