I have a requirement I have datetime component user can select the time maximum 2 hours from their current time else there should be validation error , i want to show the current time defaulted in the time field and they should select the time upto 2 hours . It should be in est . Can anyone help me with this
Discussion posts and replies are publicly visible
Try this
a!localVariables( local!selectedTime: now(), a!dateTimeField( label: "Select Time (max 2h from now)", value: local!selectedTime, saveInto: local!selectedTime, validations: ( if( local!selectedTime > addhours(now(), 2), "Select time within 2 hours from current time", {} ) ) ) )
In addition to this, if you're pre-setting the value i.e. in "local!selectedTime", and it's the save target as seen here, assuming it's in a task where the value is expected to be saved somewhere, the "Submit" button (preferably, among various options) will need to make sure to save the value contained in "local!selectedTime" into the Rule Input value (and/or whatever CDT or Record Data is being passed out of the form upon submission), otherwise the user's selected value will just get lost upon submission.