function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shashi kanaparthishashi kanaparthi 

Redirecting users to Opportunity detail page using on click java script button

Hi,

I am gettign the error "Field Quote.OpportunityId does not exist." when i use the below code.. let me know what the issue could be.


{!RequireScript("/soap/ajax/33.0/connection.js")}

var url = parent.location.href;

var OppId='{!Quote.OpportunityId}'

var sync = '{!Quote.IsSyncing }'
var conversion = '{!Quote.Conversion_Status__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
{
var r = confirm("Do not click the Quote to CW Button more than once.Note that you can only send Quote to CW one time. Are you sure you want to send? Once you click Ok, this page will redirect");
}

if(r==true)
{

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)


function processSuccess(message)
{ // do something with results¨
//alert("Quote has been synced to CW, don't click the Quote>CW Button Again. This //page will now redirect");

parent.location.href= '/' + OppId;
}
function processError(message)
{ // do something with the error
alert('error');
}
}
Mahesh DMahesh D
Hi Shashi,

Please use the below code:
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
Please do let me know if it helps you.

Regards,
Mahesh