0

We have a button on the opportunity object that is a part of the Octive managed package and is submitting the proposal for an approval when clicked. We would like to customize it so that when the opportunity is at stage 'Closed or Lost' or 'Closed or Won' and user clicks the button they get an error message.

The button URL is as following:

/apex/tinderbox__create_document?sObjectType=Opportunity&recordId={!Opportunity.Id}

1 Answer 1

0

Without knowing anything about this package, generically speaking, you can change it to a JavaScript button:

var url = '/apex/tinderbox__create_document?sObjectType=Opportunity&recordId={!Opportunity.Id}';
if({!ISPICKVAL(Opportunity.StageName,'Closed or Lost') || ISPICKVAL(Opportunity.StageName,'Closed or Won')}) {
    alert('You cannot do this.');
} else {
    if(sforce && sforce.one) {
        sforce.one.navigateToUrl(url);
    } else if(sforce && sforce.console) {
        sforce.console.openPrimaryTab(null, url);
    } else {
        window.top.location = url;
    }
}

You'll need to change the Behavior to "Onclick JavaScript."

1
  • Worked like a charm! @sfdcfox
    – Liubov
    Commented Aug 10, 2017 at 15:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .