Set the Default Value of CDT Fields Based on a User Input

SAIL Recipes give you an opportunity to explore different interface design patterns. To learn how to directly use SAIL recipes within your interfaces, see Adapt a SAIL Recipe to Work with My Applications.

Goal

Set the value of a CDT field based on a user input.

This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.

Expression

=load(
  local!myCdt: 'type!{http://www.appian.com/ae/types/2009}LabelValue'(),
  a!formLayout(
    label: "SAIL Example: Default Value Based on User Input",
    instructions: "local!myCdt: " & local!myCdt,
    contents: {
      a!textField(
        label: "Label",
        instructions: "Value saved: " & local!myCdt.label,
        value: local!myCdt.label,
        saveInto: {
          local!myCdt.label,
          a!save(local!myCdt.value, append(save!value, "@example.com"))
        },
        refreshAfter: "KEYPRESS"
      ),
      a!textField(
        label: "Value",
        instructions: "Value saved: " & local!myCdt.value,
        value: local!myCdt.value,
        saveInto: local!myCdt.value,
        refreshAfter: "KEYPRESS"
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: a!buttonWidgetSubmit(
        label: "Submit"
      )
    )
  )
)

Test it out

  1. Type into the first text field, and notice that the second text field is pre-populated. The instructions of the form show the value of the CDT variable.

To write your data to process

Any Type is not a supported data type in the process modeler. Before creating the process model, you will need to create a CDT that matches the data structure of local!myCdt.
  1. Save your interface as sailRecipe
  2. Create interface input: myCdt (CDT)
  3. Remove the load() function
  4. Delete local variable: local!myCdt
  5. In your expression, replace:
    • local!myCdt with ri!myCdt
  6. In your process model, on the process start form or forms tab of an activity, enter the name of your interface in the search box and select it
  7. Click Yes when the process modeler asks, "Do you want to import the interface inputs?"
    • On a task form, change the records node inputs to data type of the CDT used in the interface.
    • On a start form, change the records process variable to data type of the CDT used in the interface.
FEEDBACK