Skip to main content

Questions tagged [enum]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
539 views

Enum syntax errors in Visual Studio Code

vscode is constantly giving me syntax errors when it comes to enum declarations. Do you know if there is any particular setting that I should switch so that the errors will disappear?
Rechu's user avatar
  • 452
0 votes
1 answer
436 views

Enum property is not visible in Flow

I have flow which is using Enum property and trying to access in the flow, but for some reason it not showing up, Enum Property Wrapper class Not showing up in Flow Any clue will be highly ...
jks's user avatar
  • 158
10 votes
1 answer
6k views

What type of Exception will Enum.valueOf throw?

In Winter 22 we are getting a long desired (if somewhat niche) feature: Use the valueOf() Enum Method to Convert a Specified String to an Enum Constant Value The valueOf() enum method converts a ...
Adrian Larson's user avatar
  • 151k
0 votes
1 answer
112 views

Can I add extra values to a global enum in a managed package when I create a new package version?

I am thinking about adding an Apex enum to my managed package (1GP currently, though I suspect that's not an important aspect here). Before doing so, I wanted to understand whether or not it is ...
Phil W's user avatar
  • 37k
4 votes
0 answers
319 views

When to use FieldDescribeOptions.FULL_DESCRIBE in SObjectField.getDescribe(options)?

Background Playing around with the SObjectField class has led me down a rabbit hole in wondering why and how I can make use of the getDescribe(options) method where options is a FieldDescribeOptions ...
TSmith's user avatar
  • 5,052
1 vote
1 answer
612 views

Type Cast String to Enum giving error in Apex

I am trying to convert String to an enum value. but I am getting null pointer exception. Below is the code which I have tried to convert. (I have checked other stackoverflow questions before asking ...
Sagar Hinsu's user avatar
0 votes
3 answers
2k views

Reading Apex enums in LWCs: "AuraEnabled fields cannot be static" when annotating enum with @AuraEnabled

I have a service class with some error types: public with sharing class ServiceClass { public enum ErrorType { ERROR } } And a controller method: @AuraEnabled(cacheable=true) public static ...
Andy Ray's user avatar
  • 1,468
1 vote
3 answers
445 views

How to declare static literal

I have a piece of code: if (testClone.testprocess__c !=null) { if (testIteration.Key__c == 'ut') { req.Status__c = 'testing'; ...
user avatar
1 vote
2 answers
4k views

Error parsing file: 'RecordAfterSave' is not a valid value for the enum 'FlowTriggerType'

I am trying to deploy the Flow-meta.xml file using vs code with salesforce dx to my scratch Org. I am getting the error 'Error parsing file: 'RecordAfterSave' is not a valid value for the enum '...
AnkushSalesforce's user avatar
2 votes
1 answer
1k views

If I know the class type of an Enum, how can I get a list of the values?

I have the following method: public XAP_ENUM_EnumConverter put(Type enumType, XAP_ENUM_EnumWrapper enumWrapper) { ENUM_WRAPPERS_BY_TYPE_MAP.put(enumType, enumWrapper); return this;...
Brian Kessler's user avatar
2 votes
1 answer
5k views

How can I use String in enum for Apex?

I have created one static string in apex like private static string HARSWARE_SOFTWARE= 'Hardware and Software'; and now this variable I am using in ENum like public Enum PSServices{...
user69533's user avatar
2 votes
1 answer
252 views

Does APEX support factory enum method from value idiom?

Apex is supposed to be based on Java which supports factory method in enums types. global enum CheckResult { PENDING, PASSED, FAILED; public static CheckResult fromResult(Boolean aBoolean) { ...
Martin of Hessle's user avatar
2 votes
0 answers
585 views

Passing enum value to AuraEnabled method [duplicate]

I have an @AuraEnabled method that has an enum as a parameter. How do I pass this in from a Lightning component? Component code: var action2 = component.get("c.doSomething"); action2.setParams({ ...
fred's user avatar
  • 3,414
0 votes
1 answer
195 views

How can I increment value of Enum?

When I declare Enum class public Enum X{A,B,C} and I have Enum variable X y and I need to increment that value, in other languages I could just write y++ to increment it, that is, to change A to B, B ...
Patlatus's user avatar
  • 17.3k
3 votes
1 answer
2k views

Pass an enum value from lightning controller to Apex

Is it possible to pass an enum value from lightning controller to Apex? Here is what I tried lightning component part const action = component.get("methodC"); action.setParams({p: "VIEW"}); ...
oobarbazanoo's user avatar
24 votes
1 answer
13k views

Switch: Enum value used in 'when expression' should be unqualified

Background I am getting this error message three times: Enum value used in 'when expression' should be unqualified In relation to this code: Schema.DisplayType fieldType = getType(fieldName); ...
Robs's user avatar
  • 9,396
13 votes
1 answer
4k views

What happened to Trigger.Operation?

A new enum TriggerOperation is documented but no corresponding variable has been added to the Trigger Context Variables documentation. I've just found out that using API 43.0, a reference to Trigger....
Keith C's user avatar
  • 136k
2 votes
2 answers
2k views

Does Enum support hyphens?

I am trying to create an enum datatype for relationships in my apex class. Below is the code I am using: public Enum Enum_RelationShipCode {Father, Mother, Brother, Sister, Uncle, Aunt, Brother-In-...
Balaji Pooruli's user avatar
1 vote
2 answers
28k views

Check if certain string exist in my enum values - salesforce

In My ENUM a list of values is added and I need to check if certain string values are in my ENUM and which is dynamically checked through a loop. public Enum KeyValues{CaseNumber, Name, OwnerId, Id} ...
SFDC's user avatar
  • 461
1 vote
1 answer
106 views

Is SoapType.Decimal a valid value?

Documentation for SoapType enum does not list Decimal as a member. But it's possible to compile a class which uses SoapType.Decimal. Could this be a problem if we use such code in a managed package?
BuddhiP's user avatar
  • 543
11 votes
1 answer
309 views

Is there a maximum number of Enum items?

The documentation on Enums doesn't specify: Is there a maximum number of Enum items?
Adrian Larson's user avatar
  • 151k
15 votes
1 answer
1k views

Enums as Map keys don't work in Batchable

I'm running into some weird behavior when using an Enum as a Key in a map. This same code works fine in other contexts, but not when in batch. I have an Enum to represent currency types: public ...
NSjonas's user avatar
  • 10.2k
2 votes
1 answer
469 views

Reference Enum on Visualforce page

Is there any way to reference a Enum in a Visualforce page? Either for comparison or display? Something like <div> {!MyEnum.Status1} </div>
Brian Triplett's user avatar
1 vote
1 answer
880 views

Enums - Expression of type 'X' has no member named 'Y'

Consider the following method: public string WriteBoundary( EndingType endingType) { string boundary = ''; if (endingType == EndingType.Cr) {// <- Error! boundary += '\n'; ...
Gup3rSuR4c's user avatar
  • 1,006
6 votes
2 answers
11k views

String to enum value [duplicate]

How can I convert String to enum value? public enum Season {WINTER, SPRING, SUMMER, FALL} Season season1; String winterString = 'WINTER'; season1 = winterString; <-- This gives error of course, ...
Vladyslav K's user avatar
  • 2,743
8 votes
2 answers
5k views

Converting/Parsing an Enumeration to a String More Generically

This is an extension of an earlier question I made. So, using the answer from the previous question I mentioned, I am able to make a generic utility that would convert/parse an Enumeration to a ...
Programmable Medley's user avatar