0

Using this page I have the following apex on a visualforce page,that I want to run when a user saves the opportunity as 'won'.

My questions are:

1. How do I add it as a popup when the user saves the opportunity?

2. How do I re-direct the user to that new Opportunity after it has been created?

<apex:page standardController='Opportunity'>
        <apex:form >
            <apex:pageBlock title='clone opportunity' mode='edit'>
                <apex:pageBlockSection title='Please Click below to clone this quote' columns='1'>
                </apex:pageBlockSection>

                <apex:pageBlockButtons >

    <apex:commandButton value='Clone' action='{!URLFOR($Action.Opportunity.Clone,<Opportunity>.id)}'/>

                </apex:pageBlockButtons>
            </apex:pageBlock>
        </apex:form>
    </apex:page>

1 Answer 1

0

I tried your code and is working perfectly fine with one modification > Just remode angular brackets here {!URLFOR($Action.Opportunity.Clone,<Opportunity>.id)} And you are good to go !

<apex:page standardController='Opportunity'>
    <apex:form>
        <apex:pageBlock title='clone opportunity' mode='edit'>
            <apex:pageBlockSection title='Please Click below to clone this quote' columns='1'>
            </apex:pageBlockSection>

            <apex:pageBlockButtons >
                <apex:commandButton value='Clone' action='{!URLFOR($Action.Opportunity.Clone,Opportunity.id)}'/>
            </apex:pageBlockButtons>

        </apex:pageBlock>
    </apex:form>
</apex:page>

Updated to your comment : yes the code will work completely fine according to your criteria > i applied if on the apex:pageblockbuttons and it is working fine.

<apex:page standardController="Opportunity">
    <apex:form >
        <apex:pageBlock title="clone opportunity" mode="edit">
            <apex:pageBlockSection title="Please Click below to clone this quote" columns="1"> </apex:pageBlockSection>

            <apex:pageBlockButtons rendered="{!IF(Opportunity.StageName=='Closed Won',true,false)}">
                <apex:commandButton value="Clone" action="{!URLFOR($Action.Opportunity.Clone,Opportunity.id)}"/>
            </apex:pageBlockButtons>

        </apex:pageBlock>
    </apex:form>
</apex:page>
2
  • Thanks for that - glad there was only a slight mistake... How do I achieve the 2 questions above? I am trying to add this to the code rendered="{!IF(Opportunity.StageName=='Closed Won',true,false}"/ > is that correct?
    – TheAdmin
    Commented Oct 16, 2017 at 13:41
  • I have updated the answer for your requirement @CoolAdminGuy Commented Oct 17, 2017 at 6:55

You must log in to answer this question.

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