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
Avinash RaviAvinash Ravi 

Display warning on button click

Hi,

I have a custom button that is used to generate an order from a Quote. Whenever that is clicked, I want to display an error msg saying this will "create a single order for the Product. do you want to continue?"

How can I do that? Right now the custom button goes like this: /flow/Quote_to_Order?QuoteID={!Quote.Id}&retURL=/{!Quote.Id}
GauravGargGauravGarg
Hi Avinash,

Please use javascript confirm box method:

Include javascript library first, then try below code
var cont =confirm("Have you considered amount?") if (cont == true) { /flow/Quote_to_Order?QuoteID={!Quote.Id}&retURL=/{!Quote.Id}; } else if(cont == false) { return false; }

Hope this will solve your problem

Thanks
Avinash RaviAvinash Ravi
Hi Gaurav,

Thanks a lot for your response. Right now when I put this piece of code into my button, it says URL no longer exists..

This might be a silly question to ask but where and how can I include the javascript library?

Thanks,
Avinash
GauravGargGauravGarg
Yes, on custom button. 

 
Avinash RaviAvinash Ravi
I'm sorry I don't understand how I should include a JavaScript library. 
GauravGargGauravGarg
Please add your changes in the below code:
 
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")} 

var agree = confirm("Are you sure you want to create an opportunity?"); 
if(agree){ 

var result = sforce.apex.execute("MeetingOpportunity","createOpportunity",{meetingID: meetingID}); 

alert(result); 

}

Thanks,
Gaurav
Avinash RaviAvinash Ravi
Is this how? because I'm getting an error saying there was a problem with the onclick javascript. I have no coding knowledge at all, so please help me out here.

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")} 

var agree = confirm("Are you sure you want to go ahead?"); 

var result = sforce.apex.execute({/flow/Quote_to_Order?QuoteID={!Quote.Id}&retURL=/{!Quote.Id}; }) 

alert(result); 

}
GauravGargGauravGarg
yes, please try below code:
 
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")} 

var agree = confirm("Are you sure you want to go ahead?"); 
if(agree){
var result = sforce.apex.execute({/flow/Quote_to_Order?QuoteID={!Quote.Id}&retURL=/{!Quote.Id}; }) 

alert(result); 

}

 
Avinash RaviAvinash Ravi
it says "problem with the onclick javascript. unexpected token /"

Thanks,
Avinash
Rohit K SethiRohit K Sethi
Hi,

Use below code for your error :
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")} 

var agree = confirm("Are you sure you want to go ahead?"); 
if(agree){
var callback = { 
	onSuccess:function(result){ 
           alert('sucess');
	}, 
	onFailure:function(error){
           alert('Fail'+error);   
	} 
	}; 
    sforce.apex.execute("Quote_to_Order","flow","QuoteID={!Quote.Id}&retURL=/{!Quote.Id}",callback); 

}




Thanks.