I need to make variable Date(Requested by date) in such a way so that user cannot select past dates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2016 09:23 AM
Hi All,
I have a variable set applied on service catalog item, in that "Requested by date" is a variable with type as date/time, I want if user selects date as current/previous date he should not be able to submit the request or alternatively past dates can be shown as readonly, he/she should not be able to select date in that scenario. Below is the screenshot attached.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2016 09:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2016 09:30 AM
I would start here:
GlideDateTime - ServiceNow Wiki
Once that's familiar, I'd do something like this, pseudocode below
Onchange script:
g_form.hideFieldMsg('impact');
if(newValue < nowDateTime){
g_form.showFieldMsg('datefield','cant select past dates','error');
}
Please note that the above glide date time objects aren't available clientside, so "nowDateTime" will have to come from somewhere.
It's not a bad idea to have a business rule that puts frequently used items on your scratchpad for easy access from the client side.
that looks like this:
onDisplay Business Rule:
g_scratchpad.currDate = nowDateTime();
Then, you retrieve it in the client script:
var nowDateTime = g_scratchpad.currDate;
We have a number of tables with "Scratchpad Management" business rules that expose information we use frequently to client side scripts. In addition to making our lives easier, it allows us to offload much of the querying that is often done in client scripts to the server side.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2016 09:44 AM
Swapnil,
I do not think Business rules will be applicable while ordering a catalog item. Write an Onchange client script and use GlideAjax to perform the date comparison on the server and return the result. Let me know if you need any help in scripting.
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2016 08:14 PM
Abhinay,
I Tried doing it..but no luck.. can you elaborate the use of GlideAjax... I'm new to SNow..Also if you can share the script will be great..
In addition to the main query.. if the user types other than integer in date-time format in 'Requested by date' field..in this scenario an error should be thrown. This is what validation I'm looking for..