There is a Javascript error in your browser console. How to fix this error

Sriharsha3
Tera Contributor

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);
});
}

1 ACCEPTED SOLUTION

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();

 

View solution in original post

9 REPLIES 9

Chuck Tomasi
Tera Patron

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?

Sriharsha3
Tera Contributor

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

 

Fabian10
Tera Guru

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.

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();
}