- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 06:05 AM
Hello, ive a service catalog page and some items to order, once user user click on the item, it shows the error as given in the question. When i check the console the following error shows up.
(g_env) [SCRIPT:EXEC] Error while running Client Script "Initialize CSD schedule fields": ReferenceError: GwtDate is not defined
How to fix it?
The catalog client script use is :
function onLoad() {
g_form.setValue("lease_start", currentTime());
g_form.setVisible("lease_end",false);
checkSoftwareRevocable();
}
function currentTime() {
var dt = new GwtDate();
dt.now();
return dt.serializeInUserFormat();
}
function checkSoftwareRevocable() {
var ga = new GlideAjax("sn_client_sf_dist.CSDAjax");
ga.addParam("sysparm_name","getSoftwareRevocable");
var catItemId = g_form.getParameter("sysparm_id");
ga.addParam("sysparm_cat_item",catItemId);
ga.getXMLAnswer(function(answer) {
if (answer == "true")
g_form.setVisible("lease_end", true);
});
}
Solved! Go to Solution.
- Labels:
-
Request Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2020 04:54 AM
Sorry for the very late answer. You basically have to do the following two things:
1. Uncomment (or remove) the line g_form.setValue("lease_start", currentTime());
2. Open the lease_start variable, add the following as default value: javascript:new GlideDateTime()
Edit: There seems to be another bug:
If you're getting a TypeError: g_form.getParameter is not a function error, change the following line from
var catItemId = g_form.getParameter("sysparm_id");
to
var catItemId = g_form.getSysId();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 06:16 AM
Have you tried Date() instead of GwtDate? The error message is stating that GwtDate() is not defined. Looks like you'll need to find another way. Try Date() and let us know what happens. I don't know that you're going to have the method serializeInUserFormat() available.
Can you help me understand what it is you are trying to accomplish ? What is the business requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 07:12 AM
Hello Tomasi,
The business requirement is to use client software distribution to install, uninstall applications to end user's machine. In that case, whenever i click on catalog item to submit request, the following error pops on the sc_cat_item page. I tried changing it to Date() but i get an error in the catalog script : TypeError: dt.now is not a function
PFA

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2018 07:34 AM
I just bumped into the same issue and there's a simple solution for that:
Uncomment the line with g_form.setValue("lease_start", currentTime()); and set new GlideDateTime(); as Default Value for the variable lease_start. In the end it does the same...
This also should be a bit faster the the OOB script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2019 11:29 AM
Can you please elaborate your solution? I am facing the same issue.
Uncomment the line with g_form.setValue("lease_start", currentTime()); and set new GlideDateTime(); as Default Value for the variable lease_start ----- I didnt understand this.
function onLoad() {
g_form.setValue("lease_start", currentTime());
g_form.setVisible("lease_end",false);
checkSoftwareRevocable();
}
function currentTime() {
var dt = new GwtDate();
dt.now();
return dt.serializeInUserFormat();
}