Checking incident opened date vs closed date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2017 02:03 PM
hi All.
I am quite new on service now
I am trying to write a script that checks if an incident closed is after the opened date.
I manage to get the closed date with g_form.getValue('closed_at'). but g_form.getValue('opened_at') return an empty value.
Help...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 11:18 AM
Hi Gilles,
g_form only works on client side and field should be available on form for fetching value. Logically closed data will be after opened date. May I know what exactly is your requirement and which script you have been trying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 01:49 PM
Hi Dilip, the script I am trying to make is something like this :
function onSubmit() {
if(g_form.getValue('closed_at') > g_form.getValue('opened_at')){
return false;
//and some other fancy stuff here.
}
}
You are right the opened date is not on the form. How can i get it?
My requirement is to avoid to closed an incident (intentionnaly or not) with a date before the opened date.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 11:18 AM
Hi Gilles,
There should be an OOB field for opened_at and closed_at. These should be populated automatically by the platform. You can then use the date time stamps and write logic against it. What is the use case for what you are looking to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 01:54 PM
hi Steven,
Sorry for my questions, whats is OOB. I have to write a script that avoid closed date typing mistake, when closing an incident.
I began with this :
function onSubmit() {
if(g_form.getValue('closed_at') > g_form.getValue('opened_at')){
return false;
}
}
not working.
thanks in advance.