You need to sign in to do that
Don't have an account?
Antoine LELEU 10
Field Name in Custom Label
Hello,
I would like use a custom label to stock a custom field name. (ex: 'Custom_Value__c' on object Opportunity).
My Label :
name = Opportunity_custom_field
value = Custom_Value__c
Then request this from apex and use it in my code :
String query = 'Select id, Name, Amount, '+ system.label.Opportunity_custom_field + 'From Opportunity';
List<oppportunity> ListOpps = Dabase.query(query);
For(opportunity opp : ListOpps){
String Oppvalue = opp.system.label.Opportunity_custom_field;
}
This works for the query as string but not for 'opp.system.label.Opportunity_custom_field' in a loop.
Anyone know the syntaxe ? is it possible to do that ?
Thank you very much
Antoine
I would like use a custom label to stock a custom field name. (ex: 'Custom_Value__c' on object Opportunity).
My Label :
name = Opportunity_custom_field
value = Custom_Value__c
Then request this from apex and use it in my code :
String query = 'Select id, Name, Amount, '+ system.label.Opportunity_custom_field + 'From Opportunity';
List<oppportunity> ListOpps = Dabase.query(query);
For(opportunity opp : ListOpps){
String Oppvalue = opp.system.label.Opportunity_custom_field;
}
This works for the query as string but not for 'opp.system.label.Opportunity_custom_field' in a loop.
Anyone know the syntaxe ? is it possible to do that ?
Thank you very much
Antoine
Please use the below code to acheive what you want :
Let me know if you have any issue.
Thanks,
Abhishek