Date field component

Certified Associate Developer

Hi All,

        I have used date field components.In that   I have two buttons with it like submit and cancel. When ever I enter invalid date and cancelled it and I again edit it it showing the invalid date as a default even though it is not storing in any of the localvariables.

Any leads can be really helpful ..

Thanks & Regards

Divya

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hi Divya, can you share the code for your date field configuration?

  • 0
    Certified Associate Developer
    in reply to GopalK

    a!localVariables(
    local!postingDate: todate("10/10/2022"),
    local!editPostingDate: false(),
    local!oldPostingDate: null,
    {
    a!richTextDisplayField(
    label: "Posting Date",
    labelPosition: "COLLAPSED",
    value: { "Posting Date" }
    ),
    a!richTextDisplayField(
    labelPosition: "COLLAPSED",
    value: {
    a!richTextItem(
    text: local!postingDate,
    link: a!dynamicLink(
    value: local!editPostingDate,
    saveInto: { a!save(local!editPostingDate, true()) },

    ),
    color: "#212121",
    size: "MEDIUM_PLUS"
    )
    },
    showWhen: not(local!editPostingDate)
    ),
    a!dateField(
    value: local!postingDate,
    saveInto: {
    a!save(local!oldPostingDate, local!postingDate),
    if(
    rule!APN_isBlank(local!postingDate),
    a!save(local!postingDate, local!oldPostingDate),
    a!save(local!postingDate, local!currentDate)
    )
    },
    showWhen: local!editPostingDate
    ),
    a!sideBySideLayout(
    items: {
    a!sideBySideItem(
    item: a!richTextDisplayField(
    value: {
    a!richTextItem(
    text: "SUBMIT",
    link: a!dynamicLink(
    saveInto: {
    if(
    rule!APN_isBlank(local!postingDate),
    a!save(
    local!ULF_cases,
    a!update(
    local!ULF_cases,
    "postingDate",
    local!oldPostingDate
    )
    ),
    a!save(
    local!ULF_cases,
    a!update(
    local!ULF_cases,
    "postingDate",
    local!postingDate
    )
    )
    ),
    a!startProcess(
    processModel: cons!ULF_PROCESS_MODELS[2],
    processParameters: { ULF_cases: local!ULF_cases }
    ),
    if(
    rule!APN_isBlank(local!postingDate),
    a!save(local!editPostingDate, true),
    a!save(local!editPostingDate, false())
    )
    }
    )
    )
    }
    ),
    showWhen: local!editPostingDate
    ),
    a!sideBySideItem(
    item: a!richTextDisplayField(
    value: {
    a!richTextItem(
    text: "CANCEL",
    link: a!dynamicLink(
    saveInto: {
    a!save(local!postingDate, local!oldPostingDate),
    a!save(local!editPostingDate, false),
    if(
    rule!APN_isBlank(local!postingDate),
    a!save(local!editPostingDate, true),
    a!save(local!editPostingDate, false())
    )
    }
    )
    )
    }
    ),
    showWhen: local!editPostingDate
    )
    }
    )
    }
    )

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    a!localVariables(
      local!postingDate: todate("10/10/2022"),
      local!editPostingDate: false(),
      local!oldPostingDate: a!refreshVariable(
        value: local!postingDate,
        refreshOnReferencedVarChange: false()
      ),
      a!cardLayout(
        contents: a!columnLayout(
          contents: {
            a!columnsLayout(
              columns: {
                a!columnLayout(
                  contents: {
                    a!richTextDisplayField(
                      label: "Posting Date",
                      labelPosition: "COLLAPSED",
                      value: { "Posting Date" }
                    ),
                    a!richTextDisplayField(
                      labelPosition: "COLLAPSED",
                      value: {
                        a!richTextItem(
                          text: local!postingDate,
                          link: a!dynamicLink(
                            value: local!editPostingDate,
                            saveInto: { a!save(local!editPostingDate, true()) },
                            
                          ),
                          color: "#212121",
                          size: "MEDIUM_PLUS"
                        )
                      },
                      showWhen: not(local!editPostingDate)
                    ),
                    a!dateField(
                      value: if(
                        rule!APN_isBlank(local!postingDate),
                        local!oldPostingDate,
                        local!postingDate
                      ),
                      saveInto: {
                        a!save(local!oldPostingDate, local!postingDate),
                        a!save(
                          local!postingDate,
                          if(
                            rule!APN_isBlank(save!value),
                            local!oldPostingDate,
                            save!value
                          )
                        ),
                        
                      },
                      showWhen: local!editPostingDate
                    )
                  }
                ),
                a!columnLayout(
                  contents: {
                    a!richTextDisplayField(),
                    a!richTextDisplayField(),
                    a!sideBySideLayout(
                      items: {
                        a!sideBySideItem(
                          item: a!richTextDisplayField(
                            value: {
                              a!richTextItem(
                                text: "SUBMIT",
                                link: a!dynamicLink(
                                  saveInto: {
                                    a!save(local!oldPostingDate, local!postingDate),
                                    a!save(local!editPostingDate, false)
                                  }
                                )
                              )
                            }
                          )
                        ),
                        a!sideBySideItem(
                          item: a!richTextDisplayField(
                            value: {
                              a!richTextItem(
                                text: "CANCEL",
                                link: a!dynamicLink(
                                  saveInto: {
                                    a!save(local!editPostingDate, false),
                                    a!save(local!postingDate, local!oldPostingDate),
                                    
                                  }
                                )
                              )
                            }
                          )
                        )
                      }
                    )
                  },
                  showWhen: local!editPostingDate
                ),
                
              }
            )
          }
        ),
        showShadow: true,
        showBorder: false
      )
    )

    In this code if I give invalid date then I cancel it it is performing correctly but if i again want to edit this it showing previous date. please give me any suggestion regarding this..

  • 0
    Certified Lead Developer
    in reply to Divya

    This is a known quirk (not exactly a bug and not exactly a feature) with respect to how the Appian Date Field works - if an invalid value is entered, the user will need to manually clear it.  The date field holds the invalid value in an internal "buffer" let's say and it never hits the save target, and it's also not affected by background changes to the "value" parameter.  The only solution is that if an invalid date is entered the user will need to manually clear it.

    For what it's worth, when I try it on my end (despite not having some of the constants you're referencing in the above code), when I enter an invalid value in the date field and press the "cancel" link, nothing happens at all, sort of as I'd expect.  But some of the save targets seem misconfigured (and some of the local variables aren't declared).

    If you can work up a 100% environment-generic reconstruction, i.e. one that doesn't rely on any of your environment's rules, constants, etc, and still exactly demonstrates the behavior you're seeing, that would be more helpful since that would mean anyone here can copy/paste the code into a blank Interface editor and reproduce your behavior.  But I still think it's probably just the unintuitive way the Date Field handles an invalid input.

    Edit: I was able to tweak a few things to make this code 100% generic, as posted below, but it still doesn't quite work right even when using valid date values.  For one thing, you've made it impossible for the date field to actually save the entered value anywhere (see my annotations near the saveInto parameter).

    a!localVariables(
      local!postingDate: todate("10/10/2022"),
      local!editPostingDate: false(),
      local!oldPostingDate: null(),
      
      local!ULF_cases: {
        postingDate: null()
      },
      local!currentDate: today(), /* i assume? */
      
      {
        a!richTextDisplayField(
          label: "Posting Date",
          labelPosition: "COLLAPSED",
          value: { "Posting Date" }
        ),
        a!richTextDisplayField(
          labelPosition: "COLLAPSED",
          value: {
            a!richTextItem(
              text: local!postingDate,
              link: a!dynamicLink(
                value: local!editPostingDate,
                saveInto: { a!save(local!editPostingDate, true()) },
    
              ),
              color: "#212121",
              size: "MEDIUM_PLUS"
            )
          },
          showWhen: not(local!editPostingDate)
        ),
        a!dateField(
          value: local!postingDate,
          saveInto: {
            a!save(local!oldPostingDate, local!postingDate),
            
            /* the following if() condition causes the value entered in the Date Field
                to NEVER be saved into the local!postingDate value. Is that intentional? */
            if(
              a!isNullOrEmpty(local!postingDate),
              a!save(local!postingDate, local!oldPostingDate),
              a!save(local!postingDate, local!currentDate)
            )
          },
          showWhen: local!editPostingDate
        ),
        a!sideBySideLayout(
          items: {
            a!sideBySideItem(
              item: a!richTextDisplayField(
                value: {
                  a!richTextItem(
                    text: "SUBMIT",
                    link: a!dynamicLink(
                      saveInto: {
                        if(
                          a!isNullOrEmpty(local!postingDate),
                          a!save(
                            local!ULF_cases,
                            a!update(
                              local!ULF_cases,
                              "postingDate",
                              local!oldPostingDate
                            )
                          ),
                          a!save(
                            local!ULF_cases,
                            a!update(
                              local!ULF_cases,
                              "postingDate",
                              local!postingDate
                            )
                          )
                        ),
                        /*a!startProcess(
                          processModel: cons!ULF_PROCESS_MODELS[2],
                          processParameters: { ULF_cases: local!ULF_cases }
                        ),*/
                        if(
                          a!isNullOrEmpty(local!postingDate),
                          a!save(local!editPostingDate, true()),
                          a!save(local!editPostingDate, false())
                        )
                      }
                    )
                  )
                }
              ),
              showWhen: local!editPostingDate
            ),
            a!sideBySideItem(
              item: a!richTextDisplayField(
                value: {
                  a!richTextItem(
                    text: "CANCEL",
                    link: a!dynamicLink(
                      saveInto: {
                        a!save(local!postingDate, local!oldPostingDate),
                        a!save(local!editPostingDate, false()),
                        if(
                          a!isNullOrEmpty(local!postingDate),
                          a!save(local!editPostingDate, true()),
                          a!save(local!editPostingDate, false())
                        )
                      }
                    )
                  )
                }
              ),
              showWhen: local!editPostingDate
            )
          }
        )
      }
    )

Reply
  • 0
    Certified Lead Developer
    in reply to Divya

    This is a known quirk (not exactly a bug and not exactly a feature) with respect to how the Appian Date Field works - if an invalid value is entered, the user will need to manually clear it.  The date field holds the invalid value in an internal "buffer" let's say and it never hits the save target, and it's also not affected by background changes to the "value" parameter.  The only solution is that if an invalid date is entered the user will need to manually clear it.

    For what it's worth, when I try it on my end (despite not having some of the constants you're referencing in the above code), when I enter an invalid value in the date field and press the "cancel" link, nothing happens at all, sort of as I'd expect.  But some of the save targets seem misconfigured (and some of the local variables aren't declared).

    If you can work up a 100% environment-generic reconstruction, i.e. one that doesn't rely on any of your environment's rules, constants, etc, and still exactly demonstrates the behavior you're seeing, that would be more helpful since that would mean anyone here can copy/paste the code into a blank Interface editor and reproduce your behavior.  But I still think it's probably just the unintuitive way the Date Field handles an invalid input.

    Edit: I was able to tweak a few things to make this code 100% generic, as posted below, but it still doesn't quite work right even when using valid date values.  For one thing, you've made it impossible for the date field to actually save the entered value anywhere (see my annotations near the saveInto parameter).

    a!localVariables(
      local!postingDate: todate("10/10/2022"),
      local!editPostingDate: false(),
      local!oldPostingDate: null(),
      
      local!ULF_cases: {
        postingDate: null()
      },
      local!currentDate: today(), /* i assume? */
      
      {
        a!richTextDisplayField(
          label: "Posting Date",
          labelPosition: "COLLAPSED",
          value: { "Posting Date" }
        ),
        a!richTextDisplayField(
          labelPosition: "COLLAPSED",
          value: {
            a!richTextItem(
              text: local!postingDate,
              link: a!dynamicLink(
                value: local!editPostingDate,
                saveInto: { a!save(local!editPostingDate, true()) },
    
              ),
              color: "#212121",
              size: "MEDIUM_PLUS"
            )
          },
          showWhen: not(local!editPostingDate)
        ),
        a!dateField(
          value: local!postingDate,
          saveInto: {
            a!save(local!oldPostingDate, local!postingDate),
            
            /* the following if() condition causes the value entered in the Date Field
                to NEVER be saved into the local!postingDate value. Is that intentional? */
            if(
              a!isNullOrEmpty(local!postingDate),
              a!save(local!postingDate, local!oldPostingDate),
              a!save(local!postingDate, local!currentDate)
            )
          },
          showWhen: local!editPostingDate
        ),
        a!sideBySideLayout(
          items: {
            a!sideBySideItem(
              item: a!richTextDisplayField(
                value: {
                  a!richTextItem(
                    text: "SUBMIT",
                    link: a!dynamicLink(
                      saveInto: {
                        if(
                          a!isNullOrEmpty(local!postingDate),
                          a!save(
                            local!ULF_cases,
                            a!update(
                              local!ULF_cases,
                              "postingDate",
                              local!oldPostingDate
                            )
                          ),
                          a!save(
                            local!ULF_cases,
                            a!update(
                              local!ULF_cases,
                              "postingDate",
                              local!postingDate
                            )
                          )
                        ),
                        /*a!startProcess(
                          processModel: cons!ULF_PROCESS_MODELS[2],
                          processParameters: { ULF_cases: local!ULF_cases }
                        ),*/
                        if(
                          a!isNullOrEmpty(local!postingDate),
                          a!save(local!editPostingDate, true()),
                          a!save(local!editPostingDate, false())
                        )
                      }
                    )
                  )
                }
              ),
              showWhen: local!editPostingDate
            ),
            a!sideBySideItem(
              item: a!richTextDisplayField(
                value: {
                  a!richTextItem(
                    text: "CANCEL",
                    link: a!dynamicLink(
                      saveInto: {
                        a!save(local!postingDate, local!oldPostingDate),
                        a!save(local!editPostingDate, false()),
                        if(
                          a!isNullOrEmpty(local!postingDate),
                          a!save(local!editPostingDate, true()),
                          a!save(local!editPostingDate, false())
                        )
                      }
                    )
                  )
                }
              ),
              showWhen: local!editPostingDate
            )
          }
        )
      }
    )

Children
No Data