CA Service Management

 View Only
  • 1.  Hide specific hours in CA Service Catalog date field

    Posted Jan 14, 2019 10:08 PM

    Hi everyone,

     

    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).

     

    I've successfully configure the javascript function to set the MinDate Value in the field, but we're currently providing service only from 08:30 to 17:30... there's a way to hide the hours that are outside this interval?

     

    Thanks for your help!



  • 2.  Re: Hide specific hours in CA Service Catalog date field

    Broadcom Employee
    Posted Jan 15, 2019 03:54 AM

    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.

    Next are some possible examples of 'date functions' to set the minimum and maxmimum data values for validation on the form.
    ==============================
    Anyone have JavaScript that will set the Date Selection on the SC form to max of 365 days.
    I want to be able to grey out any date beyond 365 days of when the form is being submitted.
    You can use a JavaScript expression similar to the following for the 'Maximum Value' form-date-field attribute:
    $(new Date().getTime() + 31556952000)
    Where 31556952000 is a year in milliseconds.
    ==============================
    As getTime() is in milliseconds you could use something like the following for the 'Minimum Value':
    $(new Date().getTime() + 259200000)
    Where, 3 x 86400000 (one day in ms) = 259200000
    ==============================
    If you have installed the reservation manager Catalog content I would recommend taking a look at Forms >
    CA Catalog Content > RM Reservation Services > CA RM Virtual Machine form.
    This contains two date fields, start/end date.

    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.



  • 3.  Re: Hide specific hours in CA Service Catalog date field

    Posted Jan 15, 2019 08:27 AM

    Hi 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).

     

    Any ideas?

    Thanks!



  • 4.  Re: Hide specific hours in CA Service Catalog date field

    Broadcom Employee
    Posted Jan 15, 2019 08:29 AM

    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)'. 

     

    Kind regards, Louis.



  • 5.  Re: Hide specific hours in CA Service Catalog date field

    Broadcom Employee
    Posted Jan 15, 2019 09:03 AM

    Good Afternoon Kevin.

     

    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).

     

    Kind regards, Louis.



  • 6.  Re: Hide specific hours in CA Service Catalog date field

    Posted Jan 15, 2019 03:01 PM

    Hi Louis,

     

    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! 



  • 7.  Re: Hide specific hours in CA Service Catalog date field
    Best Answer

    Posted Jan 16, 2019 02:31 AM

    Hi everyone,

     

    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.

     

    Thanks!



  • 8.  Re: Hide specific hours in CA Service Catalog date field

    Broadcom Employee
    Posted Jan 16, 2019 02:38 AM

    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.