I have updated your code and it works in my DE. The code: <apex:page standardController="Opportunity"> <apex:includeScript value="/soap/ajax/34.0/connection.js" />
var AgeAdv = new Object(); AgeAdv.openWizard = function(){ if( {!(Opportunity.Name == 'D6') } ) { 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();<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.Name == 'D6')
}
)
{
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>
</apex:page> OutputOutput: When I open an Opportunity with name D6, I get redirected to https://ServerName/apex/OpportunityEditOverride?Id=00628000007wcxBAAQ
When I open an Opportunity with name D1, the standard Opportunity page opens https://ServerName/00628000007wcDAAAY/e?retURL=%2F00628000007wcDAAAY