Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
10 replies
Subscribers
7 subscribers
Views
3370 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Hello All, This might be silly but I am not able to find any solution
tapans
over 8 years ago
Hello All,
This might be silly but I am not able to find any solution for this. Seeking a help over here.
I have used datetime field to display Goal date. Put validation on that field so that user can't select past date. Now many a times user just selects date in past and not selecting any time and submits the form for further process. In this case the validation is not applied as it will only be applicable when both date and time are selected.
I am in need of some way so that I can display some default time (let say 12:00AM) so when user selects only date, the validation should be applied and it gives result.
Attached screenshot for better understanding. Let me know your thoughts.
Thanks!
OriginalPostID-209005
OriginalPostID-209005
Discussion posts and replies are publicly visible
0
kara.peeler
Appian Employee
over 8 years ago
Hello, Tapan.
Can you try to:
- Preserve "required:true"
- Add a custom validation too as seen below
Example
a!dateTimeField(
label: "Registration Date and Time",
labelPosition: "ABOVE",
saveInto: ri!myDateTime,
value:ri!myDateTime,
required: true,
validations:if(isnull(ri!myDateTime), "Registration date and time is required", null)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
tapans
over 8 years ago
Hello Kara, thanks for your input.
But as per our requirement this is optional field and I can't make it mandatory.
If user interacts with this field and only selects date (past date), the validation is not applied. I need someway so that I can give some default time already displayed so upon selection of date part validation could apply.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Robert Shankin
Appian Employee
over 8 years ago
Tapan -
A low overhead approach to solving this problem could be to add a checkbox indicating that a goal will be set.
You can configure the date time field to be disabled, and not required unless a "Set a Goal" checkbox is checked.
Use the checked value of this checkbox to drive the behavior of the datetime, e.g. when checked, required = true, and disabled = false; when unchecked, required = false, and disabled = true.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
This is tricky as a datetime without time is NULL. To get around this, you could have the datetimefield disabled, add a checkbox "Override goal" and if checked, enable the datetimefield and make it mandatory.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Peter Lewis
Appian Employee
over 8 years ago
Hi Tapan, it looks like it will still execute a save when you only put in the date, so you can use a!save() to add a trigger for testing this. Try the attached code and see if that matches what you need.
Date Validation.txt
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sanjeevg
over 8 years ago
Tapan,
if your Goal field is a optional field then try below example, this may be helpful for you.
a!dateTimeField(
label: "Goal Date and Time",
labelPosition: "ABOVE",
saveInto: ri!goalDateTime,
value: ri!goalDateTime,
validations: if(
isnull(
ri!goalDateTime
),
"Time is required with Goal date",
if(
ri!goalDateTime < now(),
"Date could not be in past",
" "
)
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
tapans
over 8 years ago
Thank you all. Really helpful. I implemented the checkbox solution which served my purpose.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sanjeevg
over 8 years ago
Tapan, if you will use above suggested solution, I think you don't need to use the checkbox. The dateTimeField will itself validate if someone only enters only date and it is not a required field.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sonalk
over 8 years ago
Hi Tapan,
You could also set the default value in the date time field with now() function value and then the validation as per your code will work.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
tapans
over 8 years ago
Hi Sanjeev/Sonal,
Completely agree with your suggestions but due to other limitation and validations in my form, the check box solution was most preferable solution.
Thanks a ton guys for your different ideas and helping hand over here. Appreciated!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel