I have a formula field which returns me a field's api name. I want to use that api name for further computation by retrieving the value stored in that field.
The field whose api name is computed by the formula field is from the Product object.
Formula field is in the Samples object.
Samples object has a lookup to Product object.
I know we can directly do this by accessing it through relationship. Like Product__r.Asia_Region_Available_Qty__c
but the reason of using the formula field was just that it is not clear until the request has been made by user. Because I have multiple quantity fields and it needs to decide by the region.
I'm able to identify the field's api name by my formula field. The actual purpose to read in the api name of the field is to use its value stored in it. Which is in fact a number. I have to use that value.
You can see below in my CASE expression that I'm using the Custom settings to bring in the fields api names.
CASE( Account__r.Office__c , "Americas", $Setup.PQFMap__c.Americas__c,
"EMEA", $Setup.PQFMap__c.EMEA__c,
"Corporate", $Setup.PQFMap__c.Corporate__c,
"Australia", $Setup.PQFMap__c.Australia__c ,
"China", $Setup.PQFMap__c.China__c ,
"Hongkong", $Setup.PQFMap__c.Hongkong__c ,
"Taiwan", $Setup.PQFMap__c.Taiwan__c ,
"Korea", $Setup.PQFMap__c.Korea__c ,
"Japan", $Setup.PQFMap__c.Japan__c ,
"India", $Setup.PQFMap__c.India__c ,
"Rest of APAC", $Setup.PQFMap__c.Rest_of_APAC__c,
" ")