- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 07:02 AM
I am very new to ServiceNow. We are trying to limit the ability to enter dates in a field to the datepicker only. I have referenced the doc -
and confirmed that the property is configured to true (we are on Helsinki). However dates still can be typed into the datepicker. I'm sure there is something easy I need to do to the field or form to enable this, but I am unable to find anything anywhere. Any help would be appreciated.
Thanks,
Keith
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 08:46 AM
Hi Keith,
You can easily achieve this via an onLoad Client Script. See below, just replace 'field_name' with the actual name of your date or date/time field.
- function onLoad() {
- // Sets the field's background to a gray, making is appear read-only.
- g_form.getControl('field_name').className='disabled';
- // Sets the field read-only
- g_form.getControl('field_name').readOnly=true;
- }
Please mark this response as correct and helpful via your post link (Configuring the datepicker ) to help others with the same question.
Thanks,
Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 08:46 AM
Hi Keith,
You can easily achieve this via an onLoad Client Script. See below, just replace 'field_name' with the actual name of your date or date/time field.
- function onLoad() {
- // Sets the field's background to a gray, making is appear read-only.
- g_form.getControl('field_name').className='disabled';
- // Sets the field read-only
- g_form.getControl('field_name').readOnly=true;
- }
Please mark this response as correct and helpful via your post link (Configuring the datepicker ) to help others with the same question.
Thanks,
Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2017 09:59 AM
This worked perfectly. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2017 05:09 AM
So now that we've tested, we've found the client script only modifies the date picker after the first save of the record. Our client is requesting that the datepicker be disable from manual entry on create as well. I have tried creating a second client script for onChange, onSubmit, and onCellEdit with no luck. Anythoughts on how I would cause the client script to kick in when I hit create new case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2017 08:10 AM
Hi Keith,
How did you go?
Please mark this response as correct and helpful via your post link (Configuring the datepicker ) to help others with the same question.
Thanks,
Robbie