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

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

 

Thomas Weyer
Tera Contributor

Is there a way to suppress this client error message in the short term? 

 

We are in the process of upgrading to London and would prefer to complete the upgrade and address the client errors post upgrade. 

Fabian10
Tera Guru

Hi Thomas

When you follow my answer just before your post, you shold have a quick and easy solution.

If my solution suits for you, please mark as helpful and as solution of the thread.

Regards,

Fabian

Dawood
Kilo Explorer

Do you suggest any Workaround to get rid of this error? "There is a JavaScript error in your browser console"

prem Kumar1
Tera Contributor

function onSubmit() {


if (g_form.getValue('portal_validation') == 'Yes') // this prevents recursion
return true;


var subcat = g_form.getValue('sub_request_type'); // 31 for non po/adv
if (subcat == '31') {
var isAtt = new GlideAjax("x_aukms_cipla_ip.getAttachmentValidation");
isAtt.addParam('sysparm_name', 'getIsAttachment');
isAtt.addParam('sysparm_sysId', g_form.getValue("record_sysid"));
isAtt.getXML(getAttachmentReponce);
//stoping form submission
return false;
}

function getAttachmentReponce(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == "true") {
alert("Acknowledge all the details submitted are verified and correct");
g_form.setValue('portal_validation', "Yes");
g_form.submit();
} else if (answer == "false") {
alert("Mandatory to attach atleast one pdf as main attachment");

}
}

}

 

 

getIsAttachment: function() {

var gr = new GlideRecord("sys_attachment");
gr.addEncodedQuery("content_type=application/pdf^table_sys_id=" + this.getParameter('sysparm_sysId'));
gr.query();
if (gr.next()) {
return "true";
} else {
return "false";
}

}

 

 

 

For this Iam getting javascript error while running in protal