You need to sign in to do that
Don't have an account?

dynamic field name in Apex
I'm building my own rule processor and I need access to field values where the field in question varies. In other words, I need something similar to the ajax syntax for returning field values:
String currentValue = oli[fname];
String currentValue = oli.get(fname);
Does anything like this work in apex? Both the above fail. Thanks.
Mark
String currentValue = oli[fname];
String currentValue = oli.get(fname);
Does anything like this work in apex? Both the above fail. Thanks.
Mark
oli.name
Not currently possible with Apex. All values must be known and hard coded at runtime. Rumor has it next version of apex will support this but there is no ETA.
http://ideas.salesforce.com/article/show/83292/Enable_Apex_Code_SOQL_queries_of_fields_not_known_at_compile_time
Mark