+ Start a Discussion
ckellieckellie 

Custom Button Javascript

How do I add three buttons on a javascript alert driven by a custom button? In my use case, I want to notify the user that not all data is entered on the opportunity page, but give the user the option to continue create a quote without the data, or return to the opportunity to add the information.

Below is the custom button:
REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT('/soap/ajax/29.0/apex.js')}
var result = sforce.connection.query("SELECT id, opportunityid, role from OpportunityContactRole where opportunityid = '{!Opportunity.Id}' and role='Technical Contact'");
var records = result.getArray("records");

var error1string = "Error:\n";
var error1found = false;
if(!records[0]==null) {
error1string += "The technical contact is not listed on the Opportunity nor will be listed on the budget proposal. Please add the technical contact to contact roles.";
error1found = true;
}


if(records[0]==null) {
alert("The technical contact is not listed on the Opportunity nor will be listed on the budget proposal. Do you want to continue to create the quote or do you want to add the technical contact?");
window.location = "{!URLFOR($Action.Opportunity.View,Opportunity.Id)}";
} else {
/apex/QuoteNotification?oppid={!Opportunity.Id}&Type="B"&Rec="Budget Quote"
}

How do I add two buttons to the alert?
Best Answer chosen by ckellie
Vivek DVivek D
Use a jQuery dialog so that you can have 3 buttons or many more. Check this out http://www.valnavjo.com/blog/bdialog-the-app/
there is a app for this on appexchange you can download and configure it.
If the app doesn’t solve the purpose it is very easy to build also
Step 1: - Create a VF page with standard controller Opportunity put it into the page layout hidden. Most of the magic will happen there.
Step 2 :- Create a button with
/* Add Jquery library fron static resource or directly. I will prefer from static resource */
{!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')} 

jQuery.dialog('Open');
/* 
It will open dialog from your page now the control is transferred to your page and you can do anything you want
Provided you have jQuery dialog code into your page  */

 
 

All Answers

Vivek DVivek D
Use a jQuery dialog so that you can have 3 buttons or many more. Check this out http://www.valnavjo.com/blog/bdialog-the-app/
there is a app for this on appexchange you can download and configure it.
If the app doesn’t solve the purpose it is very easy to build also
Step 1: - Create a VF page with standard controller Opportunity put it into the page layout hidden. Most of the magic will happen there.
Step 2 :- Create a button with
/* Add Jquery library fron static resource or directly. I will prefer from static resource */
{!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')} 

jQuery.dialog('Open');
/* 
It will open dialog from your page now the control is transferred to your page and you can do anything you want
Provided you have jQuery dialog code into your page  */

 
 
This was selected as the best answer
ckellieckellie
Thank you