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
jeremyyjeremyy 

Having trouble referencing a user defined enum

Have the following enum in a controller extension:

 

 

public enum ApprovalState { NotRequired, Required, Pending }

public ApprovalState CurrentApprovalState { get; set; }

 

 

And the following VF snippet:

 

 

<apex:commandButton disabled="{!currentApprovalState != ApprovalState.NotRequired}" />

 

When I attempt to save the VF page, I get "Save error: Unknown property 'Quote__cStandardController.ApprovalState'"
 
 Am I using the wrong syntax to access the enum data type?

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
hemmhemm

I had the same issue.  I don't think you can directly reference the enum since the enum itself is not visible to the page and you can't make it a property.  I resolved the issue by adding in one more controller property.

 

public String CurrentApprovalStateForVF { get{return CurrentApprovalState.name();}}

 

Then change your page to be:

 

<apex:commandButton disabled="{!currentApprovalStateForVF != 'NotRequired'}" />

 

 

 

 

 

All Answers

paul-lmipaul-lmi
you have a custom class, but your VF page is using the standard controller?  you need to either use this class as the controller, or do an extension.
jeremyyjeremyy
As I said in the OP, I'm using a controller extension.  The error message is misleading in this regard.
jwolfjwolf
I'm also trying to reference an enum from my visualforce page that is defined in my custom controller extension, but I am running into the same error shown above. Did you have any luck figuring this out? This would be really useful.
hemmhemm

I had the same issue.  I don't think you can directly reference the enum since the enum itself is not visible to the page and you can't make it a property.  I resolved the issue by adding in one more controller property.

 

public String CurrentApprovalStateForVF { get{return CurrentApprovalState.name();}}

 

Then change your page to be:

 

<apex:commandButton disabled="{!currentApprovalStateForVF != 'NotRequired'}" />

 

 

 

 

 

This was selected as the best answer