I am trying to create a Visualforce page that intercepts the "New Case" button on the account when billing status = cancelled and returns an error that a case can not be created. If billing status <> cancelled, then the New Case page should load like normal.
When I use the code below, I end up basically cycling through the New Case creation. I'm brought to the record type select page, then when I choose a record type it brings be back to the record type select page and then proceeds like normal. Ideally, I shouldn't be coming to the record type select page at all if the billing stats = cancelled.
I believe I've isolated the error down to the field criteria itself. If I flip the logic and use billing status <> cancelled, I'm brought to the error page that should be displayed when billing status = cancelled.
I am wondering if I am running into an issue with the Case Standard Controller trying to reference a custom field on the related account. I've created similar use cases using the Profile as the criteria in the IF statement without issue.
Any guidance on this would be very helpful! 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>