You need to sign in to do that
Don't have an account?
Custom Button Code Help
I am having trouble with what I imagine to be some pretty basic Javascript. I have been struggling for days and decided I would just post and hope some kind soul will help me out :-)
Ok, so.....
I am looking to put a custom button on my Opportunity with the following methodology:
IF [Opportunity.Closed] = TRUE & [Opportunity.Dropped_Products__c] = TRUE,
Display Alert ("You will now be redirected to Product History"), Save Opportunity, and then redirect user to 'https://cs14.salesforce.com/apex/clonedrop?id={!Opportunity.Id}'
OTHERWISE
Save opportunity as usual
Any help would be GREATLY appreciated!! Thank you!
For this you have to create custom page for opportunity and create button on vf page
On button click use this snippet
<input type="button" value="Click.." onclick="callFunc();"/>
function callFunc(){
if({!Opportunity.Closed} && {!Opportunity.Dropped_Products__c}){
alert("You will now be redirected to Product History");
// for save opp. use actionFunction tag to save opp and redirect user to other page
saveOpp();
}
else{
saveOpp1();
}
}
// Apex code
public PageReference saveOpp(){
update opp;
}
<apex:actionfunction name="saveOpp" action="{!saveOpp}" oncomplete="window.location.href="/apex/clonedrop?id={!Opportunity.Id}";"/>
<apex:actionfunction name="saveOpp1" action="{!saveOpp}"/>