You need to sign in to do that
Don't have an account?
shashi kanaparthi
Identifying the line in which "undefined" error occurs java script
Hi,
I have a button which used the below java script code, when i click on the button i get the error "undefined", i am unable to identify the line at which this error is occuring, can you let me know if there is a way to identify the line which is causing this error:-
{!RequireScript("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")}
{!REQUIRESCRIPT("//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js")}
{!REQUIRESCRIPT("//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js")}
try{
jQuery(function() {
/*Append the jQuery CSS CDN Link to the Head tag.*/
jQuery('head').append('<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/start/jquery-ui.css" type="text/css" />');
/*Create the HTML(DIV Tag) for the Dialog.*/
var html =
'<div id="dialog" title="Go To Opportunity"><p>Do you want to go to the Opportunity Home Page? Click continue or this page will redirect automatically </p></div>';
/*Check if the Dialog(DIV Tag) already exists if not then Append the same to the Body tag.*/
if(!jQuery('[id=dialog]').size()){
jQuery('body').append(html);
}
/*Open the jQuery Dialog.*/
jQuery( "#dialog" ).dialog({
autoOpen: true,
modal: true,
show: {
effect: "bounce",
duration: 1000
},
hide: {
effect: "bounce",
duration: 1000
},
buttons: {
"Continue": function() {
parent.location.href= '/' + '{!Quote.Opportunity_ID_18_Char__c}' ; /* redisplay the detail page */
jQuery( this ).dialog( "close" );
},
Cancel: function() {
jQuery( this ).dialog( "close" );
}
}
});
});
}
catch(e){
alert('An Error has Occured. Error: ' + e);
}
var sync = '{!Quote.IsSyncing }'
var conversion = '{!Quote.Conversion_Status__c}'
var QuoteObj = new sforce.SObject("Quote");
QuoteObj.Id='{!Quote.Id}';
var OppId='{!Quote.Opportunity_ID_18_Char__c}'
var Q='{!Quote.Quote_CW__c}'
if( sync == false)
{
alert("Please sync your quote before continuing");
}
else if( conversion == 'Sent')
{
alert("Your Quote has already been sent to CW");
}
else if(Q==true) {
alert("You already have clicked on the Button once");
}
else
{
var r = confirm("Note that you can only send Quote to CW one time. Are you sure you want to send?");
/*var query="select id,Quote_CW__c from Quote where Id='{!Quote.Id}' ";
var records = sforce.connection.query(query);
var records1 = records.getArray("records"); */
//alert(records);
}
if(r==true)
{
QuoteObj.Quote_CW__c=true;
var result = sforce.connection.update([QuoteObj]);
//alert(result);
var quoteID = '{!Quote.Id}'
postParams = {}
postParams.url = 'https://servicesuat.restorationhardware.com:10000/QuoteToCW/' + quoteID
postParams.method = 'GET'
postParams.requestHeaders = {}
postParams.requestData = ''
postParams.requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded' //or another mime-type
postParams.requestHeaders['Content-Length'] = postParams.requestData.length //required for POST
postParams.onSuccess = processSuccess
postParams.onError = processError
sforce.connection.remoteFunction(postParams)
if (result[0].success == 'false') {
alert(result[0].errors.message);
}
else {
parent.location.href= '/' + OppId; /* redisplay the detail page */
}
function processSuccess(message)
{ // do something with results
alert(message);
/*alert("Don't click on the Quote>CW again, it will be duplicate orders. This page will now redirect"); */
//document.getElementsByName("Quote>CW")[0].disabled = true;
}
function processError(message)
{ // do something with the error
alert('error');
}}
I have a button which used the below java script code, when i click on the button i get the error "undefined", i am unable to identify the line at which this error is occuring, can you let me know if there is a way to identify the line which is causing this error:-
{!RequireScript("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")}
{!REQUIRESCRIPT("//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js")}
{!REQUIRESCRIPT("//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js")}
try{
jQuery(function() {
/*Append the jQuery CSS CDN Link to the Head tag.*/
jQuery('head').append('<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/start/jquery-ui.css" type="text/css" />');
/*Create the HTML(DIV Tag) for the Dialog.*/
var html =
'<div id="dialog" title="Go To Opportunity"><p>Do you want to go to the Opportunity Home Page? Click continue or this page will redirect automatically </p></div>';
/*Check if the Dialog(DIV Tag) already exists if not then Append the same to the Body tag.*/
if(!jQuery('[id=dialog]').size()){
jQuery('body').append(html);
}
/*Open the jQuery Dialog.*/
jQuery( "#dialog" ).dialog({
autoOpen: true,
modal: true,
show: {
effect: "bounce",
duration: 1000
},
hide: {
effect: "bounce",
duration: 1000
},
buttons: {
"Continue": function() {
parent.location.href= '/' + '{!Quote.Opportunity_ID_18_Char__c}' ; /* redisplay the detail page */
jQuery( this ).dialog( "close" );
},
Cancel: function() {
jQuery( this ).dialog( "close" );
}
}
});
});
}
catch(e){
alert('An Error has Occured. Error: ' + e);
}
var sync = '{!Quote.IsSyncing }'
var conversion = '{!Quote.Conversion_Status__c}'
var QuoteObj = new sforce.SObject("Quote");
QuoteObj.Id='{!Quote.Id}';
var OppId='{!Quote.Opportunity_ID_18_Char__c}'
var Q='{!Quote.Quote_CW__c}'
if( sync == false)
{
alert("Please sync your quote before continuing");
}
else if( conversion == 'Sent')
{
alert("Your Quote has already been sent to CW");
}
else if(Q==true) {
alert("You already have clicked on the Button once");
}
else
{
var r = confirm("Note that you can only send Quote to CW one time. Are you sure you want to send?");
/*var query="select id,Quote_CW__c from Quote where Id='{!Quote.Id}' ";
var records = sforce.connection.query(query);
var records1 = records.getArray("records"); */
//alert(records);
}
if(r==true)
{
QuoteObj.Quote_CW__c=true;
var result = sforce.connection.update([QuoteObj]);
//alert(result);
var quoteID = '{!Quote.Id}'
postParams = {}
postParams.url = 'https://servicesuat.restorationhardware.com:10000/QuoteToCW/' + quoteID
postParams.method = 'GET'
postParams.requestHeaders = {}
postParams.requestData = ''
postParams.requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded' //or another mime-type
postParams.requestHeaders['Content-Length'] = postParams.requestData.length //required for POST
postParams.onSuccess = processSuccess
postParams.onError = processError
sforce.connection.remoteFunction(postParams)
if (result[0].success == 'false') {
alert(result[0].errors.message);
}
else {
parent.location.href= '/' + OppId; /* redisplay the detail page */
}
function processSuccess(message)
{ // do something with results
alert(message);
/*alert("Don't click on the Quote>CW again, it will be duplicate orders. This page will now redirect"); */
//document.getElementsByName("Quote>CW")[0].disabled = true;
}
function processError(message)
{ // do something with the error
alert('error');
}}
Regards,
Mahesh