Auto Populate

Hi,

I have two date fields last-updated and next-update,

when i enter last-updated date then next-update field need to be auto populated (last-upadate+2years= next-update)

how can i achieve this?

Thanks,

Kavya 

  Discussion posts and replies are publicly visible

Parents
  • When your user selects a value for the 'last-updated' date you can add, on that same date field component, an a!save() to save the derived value of last-upadate+2years into the variable that you are using as the value attribute of your 'next-update' field. Assuming you don't want your user to override the 'next-update' value you should make this read-only and use a different component to display its value (i.e. the underlying variable type will be date but a read-only display of this value should be a text field, where you can use the text() function to render a friendly date, like "Tuesday 25th March 2022")

  • Here's an example of what I meant:

    a!localVariables(
      local!lastUpdated: null,
      local!nextUpdate: null,
      {
        a!dateField(
          label: "Last UHpdated",
          value: local!lastUpdated,
          saveInto: {
            local!lastUpdated,
            a!save(
              local!nextUpdate,
              local!lastUpdated + (365 * 2)
            )
          }
        ),
        a!textField(
          label: "Next Update",
          readOnly: true,
          value: if(
            fn!isnull(local!nextUpdate),
            "",
            fn!text(local!nextUpdate, "ddd mmm yyyy")
          )
        )
      }
    )

Reply Children
No Data