function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ErikEitelErikEitel 

Override New Case Button with Visualforce Page

Hi All-

I am trying to override the New Case button on accounts when account Billing Status = Cancelled. This is what I have so far, but I'd love some input. When I click the New Case button, instead of generating my VF error page, it asks me to select a record type, and when I do, it just goes back to the record type selection page. In theory I shouldn't even be getting to the record type selection when the criteria is met, but should just be sent to the VF error page I created. I have to use the Case standardController to override the New Case button, but I wonder if that's my issue since I'm trying to prevent an action from happening when there's no case to reference. Thanks!
 
<apex:page standardController="Case"
action="
  {!
  IF(case.Account.Billing_Status__c == 'Cancelled', 
       URLFOR($Page.CasePageMessenger, case.id,[id=case.id],FALSE),
       URLFOR($Action.Case.NewCase, case.id,[retURL="/001"], TRUE)
    )
  }">
<apex:pageMessage severity="ERROR" 
    strength="3" 
    title="Case Create" 
    summary="This Account is cancelled and can not receive support.">
</apex:pageMessage>
</apex:page>

 
kevin lamkevin lam
Did you check the "Skip Record Type Selection Page" option when overriding the New button?
ErikEitelErikEitel
I did. I've isolated the issue to the case.Account.Billing_Status__c field. When I switch the == to <> it will trigger the $Page.CasePageMessenger url even if case.Account.Billing_Status__c == 'Cancelled' indicates it should go to the 2nd URL in the IF statement.