Skip to main content
added 34 characters in body
Source Link
J. Neilan
  • 1.2k
  • 4
  • 23
  • 54

I am trying to find a workaround for an issue using Javascript and Visualforce, but I am not very familiar with Javascript. Essentially, when a user creates a new Opportunity or tries to edit an existing Opportunity whose related Account is a certain type and a particular field on the Opportunity is empty, the user should be re-directed to a Visualforce page. Otherwise, they should just be directed to the standard edit page for the Opportunity. I am doing it this way rather than replacing the Edit button with a VF page because I want to also maintain the ability of in-line editing on the Opp, which cannot be done if the edit button is overridden. So I am trying to embed the VF page below in my Opp to fire whenever the Opp is edited and the conditions are met. It's not working, as it doesn't do anything. Does anyone see an issue why it would not pull up the VF page?

<apex:page standardController="Opportunity">
    <apex:includeScript value="/soap/ajax/34.0/connection.js" />
    <script type="text/javascript">
        var AgeAdv = new Object();

        AgeAdv.openWizard = function(){
            if(
                {!(Opportunity.Account.Type == 'Ag') &&
                ISBLANK(Opportunity.Ad__c) &&
                CONTAINS(Opportunity.RecordType.Name,'New')
                }
            )
                {
                window.parent.location.href = "/apex/OpportunityEditOverride?Id={!Opportunity.Id}";                    );
                }else
                {
                window.parent.location.href = "/{!Opportunity.Id}/e?retURL=%2F{!Opportunity.Id}";
                }
            return this;
        };
        AgeAdv.openWizard();
    </script>
</apex:page>

I am trying to find a workaround for an issue using Javascript and Visualforce, but I am not very familiar with Javascript. Essentially, when a user creates a new Opportunity or tries to edit an existing Opportunity whose related Account is a certain type and a particular field on the Opportunity is empty, the user should be re-directed to a Visualforce page. Otherwise, they should just be directed to the standard edit page for the Opportunity. I am doing it this way rather than replacing the Edit button with a VF page because I want to also maintain the ability of in-line editing on the Opp, which cannot be done if the edit button is overridden. So I am trying to embed the VF page below in my Opp to fire whenever the Opp is edited and the conditions are met. It's not working, as it doesn't do anything. Does anyone see an issue why it would not pull up the VF page?

<apex:page standardController="Opportunity">
    <apex:includeScript value="/soap/ajax/34.0/connection.js" />
    <script type="text/javascript">
        var AgeAdv = new Object();

        AgeAdv.openWizard = function(){
            if(
                {!(Opportunity.Account.Type == 'Ag') &&
                ISBLANK(Opportunity.Ad__c) &&
                CONTAINS(Opportunity.RecordType.Name,'New')
                }
            )
                {
                window.parent.location.href = "/apex/OpportunityEditOverride?Id={!Opportunity.Id}";                    );
                }else
                {
                window.parent.location.href = "/{!Opportunity.Id}/e?retURL=%2F{!Opportunity.Id}";
                }
            return this;
        };
    </script>
</apex:page>

I am trying to find a workaround for an issue using Javascript and Visualforce, but I am not very familiar with Javascript. Essentially, when a user creates a new Opportunity or tries to edit an existing Opportunity whose related Account is a certain type and a particular field on the Opportunity is empty, the user should be re-directed to a Visualforce page. Otherwise, they should just be directed to the standard edit page for the Opportunity. I am doing it this way rather than replacing the Edit button with a VF page because I want to also maintain the ability of in-line editing on the Opp, which cannot be done if the edit button is overridden. So I am trying to embed the VF page below in my Opp to fire whenever the Opp is edited and the conditions are met. It's not working, as it doesn't do anything. Does anyone see an issue why it would not pull up the VF page?

<apex:page standardController="Opportunity">
    <apex:includeScript value="/soap/ajax/34.0/connection.js" />
    <script type="text/javascript">
        var AgeAdv = new Object();

        AgeAdv.openWizard = function(){
            if(
                {!(Opportunity.Account.Type == 'Ag') &&
                ISBLANK(Opportunity.Ad__c) &&
                CONTAINS(Opportunity.RecordType.Name,'New')
                }
            )
                {
                window.parent.location.href = "/apex/OpportunityEditOverride?Id={!Opportunity.Id}";                    );
                }else
                {
                window.parent.location.href = "/{!Opportunity.Id}/e?retURL=%2F{!Opportunity.Id}";
                }
            return this;
        };
        AgeAdv.openWizard();
    </script>
</apex:page>
added 4 characters in body
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

I am trying to find a workaround for an issue using Javascript and Visualforce, but I am not very familiar with Javascript. Essentially, when a user creates a new Opportunity or tries to edit an existing Opportunity whose related Account is a certain type and a particular field on the Opportunity is empty, the user should be re-directed to a Visualforce page. Otherwise, they should just be directed to the standard edit page for the Opportunity. I am doing it this way rather than replacing the Edit button with a VF page because I want to also maintain the ability of in-line editing on the Opp, which cannot be done if the edit button is overridden. So I am trying to embed the VF page below in my Opp to fire whenever the Opp is edited and the conditions are met. It's not working, as it doesn't do anything. Does anyone see an issue why it would not pull up the VF page?

<apex:page standardController="Opportunity"> <apex:includeScript value="/soap/ajax/34.0/connection.js" /> var AgeAdv = new Object();

<apex:page standardController="Opportunity">
    <apex:includeScript value="/soap/ajax/34.0/connection.js" />
    <script type="text/javascript">
        var AgeAdv = new Object();

        AgeAdv.openWizard = function(){
            if(
                {!(Opportunity.Account.Type == 'Ag') &&
                ISBLANK(Opportunity.Ad__c) &&
                CONTAINS(Opportunity.RecordType.Name,'New')
                }
            )
                {
                window.parent.location.href = "/apex/OpportunityEditOverride?Id={!Opportunity.Id}";                    );
                }else
                {
                window.parent.location.href = "/{!Opportunity.Id}/e?retURL=%2F{!Opportunity.Id}";
                }
            return this;
        };
    </script>
</apex:page>

I am trying to find a workaround for an issue using Javascript and Visualforce, but I am not very familiar with Javascript. Essentially, when a user creates a new Opportunity or tries to edit an existing Opportunity whose related Account is a certain type and a particular field on the Opportunity is empty, the user should be re-directed to a Visualforce page. Otherwise, they should just be directed to the standard edit page for the Opportunity. I am doing it this way rather than replacing the Edit button with a VF page because I want to also maintain the ability of in-line editing on the Opp, which cannot be done if the edit button is overridden. So I am trying to embed the VF page below in my Opp to fire whenever the Opp is edited and the conditions are met. It's not working, as it doesn't do anything. Does anyone see an issue why it would not pull up the VF page?

<apex:page standardController="Opportunity"> <apex:includeScript value="/soap/ajax/34.0/connection.js" /> var AgeAdv = new Object();

        AgeAdv.openWizard = function(){
            if(
                {!(Opportunity.Account.Type == 'Ag') &&
                ISBLANK(Opportunity.Ad__c) &&
                CONTAINS(Opportunity.RecordType.Name,'New')
                }
            )
                {
                window.parent.location.href = "/apex/OpportunityEditOverride?Id={!Opportunity.Id}";                    );
                }else
                {
                window.parent.location.href = "/{!Opportunity.Id}/e?retURL=%2F{!Opportunity.Id}";
                }
            return this;
        };
    </script>
</apex:page>

I am trying to find a workaround for an issue using Javascript and Visualforce, but I am not very familiar with Javascript. Essentially, when a user creates a new Opportunity or tries to edit an existing Opportunity whose related Account is a certain type and a particular field on the Opportunity is empty, the user should be re-directed to a Visualforce page. Otherwise, they should just be directed to the standard edit page for the Opportunity. I am doing it this way rather than replacing the Edit button with a VF page because I want to also maintain the ability of in-line editing on the Opp, which cannot be done if the edit button is overridden. So I am trying to embed the VF page below in my Opp to fire whenever the Opp is edited and the conditions are met. It's not working, as it doesn't do anything. Does anyone see an issue why it would not pull up the VF page?

<apex:page standardController="Opportunity">
    <apex:includeScript value="/soap/ajax/34.0/connection.js" />
    <script type="text/javascript">
        var AgeAdv = new Object();

        AgeAdv.openWizard = function(){
            if(
                {!(Opportunity.Account.Type == 'Ag') &&
                ISBLANK(Opportunity.Ad__c) &&
                CONTAINS(Opportunity.RecordType.Name,'New')
                }
            )
                {
                window.parent.location.href = "/apex/OpportunityEditOverride?Id={!Opportunity.Id}";                    );
                }else
                {
                window.parent.location.href = "/{!Opportunity.Id}/e?retURL=%2F{!Opportunity.Id}";
                }
            return this;
        };
    </script>
</apex:page>
Source Link
J. Neilan
  • 1.2k
  • 4
  • 23
  • 54

Javscript Function to Re-Direct Upon Edit/Save

I am trying to find a workaround for an issue using Javascript and Visualforce, but I am not very familiar with Javascript. Essentially, when a user creates a new Opportunity or tries to edit an existing Opportunity whose related Account is a certain type and a particular field on the Opportunity is empty, the user should be re-directed to a Visualforce page. Otherwise, they should just be directed to the standard edit page for the Opportunity. I am doing it this way rather than replacing the Edit button with a VF page because I want to also maintain the ability of in-line editing on the Opp, which cannot be done if the edit button is overridden. So I am trying to embed the VF page below in my Opp to fire whenever the Opp is edited and the conditions are met. It's not working, as it doesn't do anything. Does anyone see an issue why it would not pull up the VF page?

<apex:page standardController="Opportunity"> <apex:includeScript value="/soap/ajax/34.0/connection.js" /> var AgeAdv = new Object();

        AgeAdv.openWizard = function(){
            if(
                {!(Opportunity.Account.Type == 'Ag') &&
                ISBLANK(Opportunity.Ad__c) &&
                CONTAINS(Opportunity.RecordType.Name,'New')
                }
            )
                {
                window.parent.location.href = "/apex/OpportunityEditOverride?Id={!Opportunity.Id}";                    );
                }else
                {
                window.parent.location.href = "/{!Opportunity.Id}/e?retURL=%2F{!Opportunity.Id}";
                }
            return this;
        };
    </script>
</apex:page>