Interface Date Field input customization

Within the Appian interface, the date field typically accepts dates separated by a forward slash ("/"). However, in our use case, there are scenarios where we need to support dates separated by a hyphen ("-") or a pipe ("|"). To accommodate this requirement, I’ve written the following piece of code

a!localVariables(
  local!onlyNumbers: cleanwith("1.22.1957", "1234567890"),
  local!length: len(local!onlyNumbers),
  if(local!length = 8,
  concat(left(local!onlyNumbers, 2), "/", mid(local!onlyNumbers, 3, 2), "/", right(local!onlyNumbers, 4)),
  if(local!length = 7,
  concat("0", left(local!onlyNumbers, 1), "/", mid(local!onlyNumbers, 2, 2), "/", right(local!onlyNumbers, 4)),
  null
  )
  ))

It seems that the Appian interface is not executing the logic as expected, and the error still persists.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Try below sample interface code..

    a!localVariables(
      local!dateInput: "",
      local!formattedDate: if(
        isnull(local!dateInput),
        null,
        a!localVariables(
          local!separator: if(
            find("-", local!dateInput) > 0, "-",
            if(find("|", local!dateInput) > 0, "|",
            if(find(".", local!dateInput) > 0, ".", "/"))
          ),
          local!parts: split(local!dateInput, local!separator),
          if(
            length(local!parts) = 3,
            concat(
              text(tointeger(local!parts[1]), "00"), "/",
              text(tointeger(local!parts[2]), "00"), "/",
              local!parts[3]
            ),
            "Invalid format"
          )
        )
      ),
      {
        a!textField(
          label: "Enter Date",
          placeholder: "MM-DD-YYYY or MM.DD.YYYY or MM|DD|YYYY",
          value: local!dateInput,
          saveInto: local!dateInput
        ),
        a!textField(
          label: "Formatted Date",
          value: local!formattedDate,
          readOnly: true
        )
      }
    )

  • Thank you, Shubham. I’d like to integrate the date values directly into the date design object, ideally with calendar selection functionality included.

  • 0
    Certified Lead Developer
    in reply to sanjuktab2257

    It is not possible to format the date field available OOTB in Appian Interface object. You need to either use textField like Shubham suggested so that user's enter dates with '-' or '|' . Otherwise have the users enter with default date field and then show with '-' or '|' when the field is read only for users. 

Reply Children
No Data