I'm trying to display a date-time field in CA Service Catalog where users can enter the need by date of the request, it should be Today() + 48 hours (2 days).
Thanks for your help!
Good Morning Kevin.
Please check the below as a possible workaround for you on this subject.
If there should be any restrictions on the date to be selected we should use 'minimum value' and 'maximum value'.To impose restrictions on the ranges that can be selected by users.
The start date restricts values less than the current time plus an hour.This is done by setting 'Minimum Value' and 'Value' to '$(new Date().getTime() + 3600000)'.Then depending on the date selected, the minimum value will be set on the end date field for the start time plus an hour.Done by specifying the following onChange of the start field:ca_fdSetDateFieldMinValue(ca_fd.formId,'end_date_time',ca_fdGetDateFieldValueInMillis(ca_fd.formId,'start_date_time') + 3600000);
Kind regards, Louis.
Thanks but I already have the MinValue working.
I need to validate that the time picked by the user should be inside the business hours (8:30 - 17:30).
Good Afternoon Kevin.
isn't that in the (part of) the comment I added:
The start date restricts values less than the current time plus an hour.This is done by setting 'Minimum Value' and 'Value' to '$(new Date().getTime() + 3600000)'.
Although you can not avoid the values to be seen, you can 'alert' when an incorrect date is chosen.
At least that is what I understand from this code (that I found and copy&paste it in here).
I checked the example, however, what it does is to restrict the start date to: GetTime() + 1 hour. Therefore, the other non labor hours continue to appear in the dropdown time list (18:00 - 23:00).
I guess is not possible to restrict the hours shown in the date field.
Anyway, thanks for your help!
I figured out how to get what I was expecting. First of all sorry for the bad english, but it isn't my native language.
Okay, so It isn't a simple a solution and take me a little bit of work, but if your payroll depends on this I think it isn't a big deal.
1. Create a database table with two columns. The first one is the business hour with all the hh:mm combinations and the other column is an int id with the format hhmm
2. In the form, the MinDate value is new Date() + 2 days (In DocOps and in the comments above is the way to do this).
3. Create two Select type fields in the form and set the Hide option to true in both or one of them.
4. Create two report object:
The first one, to get all the possible business hours after the present time (this one should be used when the user selects Date = MinDate):
SELECT hour as id, hour FROM test_hour WHERE id >= DATEPART(HH,GETDATE())*100
The other object get all the possible business hours from the table, regardless of the present time (this one should be used when the user selects Date != MinDate)
SELECT hour as id, hour FROM test_hour
5. Configure the Select fields with the corresponding report objects.
6. Create a function to validate if the user selected Date == MinDate show/hide the respective Select field and vice versa with Date != MinDate. It should be called in the onChange event of the Date field.
Now the user can choose dynamically according to the GETDATE() function if the closest day is selected, or can select any business hour if any other day is chosen.
Wow Kevin. GREAT JOB!! And thanks for sharing. I'll keep this in a 'save place' for possible future use.
Thanks again and kind regards, Louis.