Catalog variable Date/Time validation – 2 working days (Sun–Thu) with hour‑based lead time

Sirri
Tera Guru

Hi Community,

I’m working on a Service Catalog Date/Time variable validation and would like confirmation or suggestions for improvement.

Variable Details

  • Variable name: time_to_send_out_comms
  • Variable type: Date/Time
  • Used on: Service Request (SR)

    Business Requirement

    1. Past Date/Time Validation

    • The selected date/time must not be in the past

    If user selects a past date/time, show the error message:

    “The time chosen to send out the communication occurs in the past, kindly select a future date/time to proceed.”

    2. Minimum Lead Time – 2 Working Days (Hour‑Based)

    • The selected date/time must be at least 2 working days after the current date/time
    • Working days: Sunday to Thursday
      (Friday and Saturday are non‑working days)
    • Lead time must be hour‑based, not just date‑based

    Example

    Current date/time:

    13/May/2026 13:05:00 (Wednesday)

    Valid selections

    • 17/May/2026 13:06:00
    • 17/May/2026 15:00:00
    • Any date/time after the same HH:mm:ss on the 2nd working day

    Invalid selections

    • 17/May/2026 13:04:00
    • Any date/time before 17/May/2026 13:05:00

    If user does not allow 2 working days lead time, show the error message:

    “Please allow two working days lead time for approvals and content review.”
    Please provide with exact code so it will helpful to me.

    Thank you

     





2 REPLIES 2

Ankur Bawiskar
Tera Patron

@Sirri 

approach

-> use onChange catalog client script and 1st check if value is in past then show error

-> if date is not in past then check business days

see this link for solution and enhance

Variable Date no less than 5 business days 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

Thank you for your response. Please can you share exact code as per my requirement. It will be helpful to me.

Thank you