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
SYM12SYM12 

How to convert String field name to field token

HI All,

 

I have stored contact field API name in other object as text.Now i am retriving that field name and need to convert as field token.

 

For eg:

list<CampSetup__c> allCampmember= [select id,ContactDate_ApiName__c,Name from CampSetup__c];
                 map<String,String> mapallcamp = new map<String,String>();


//map defines campaign name as key and contact date field Api name as value        

        if(!allCampmember.isEmpty())
             {
                  for(CampSetup__c cc :allCampmember)
                  {
                      mapallcamp.put(cc.Name,cc.ContactDate_ApiName__c);
                  }
            }

 

now i have all the field name values in my map

Campaign  camp = [select id,name from CampaignMember where id ='abdcksf'];

CampaignMember con = [select id,name,Contact.abcd__c from CampaignMember where id ='abdcksf'];

when i try try to access

Date dd =con.Contact.(mapallcamp.get(camp.name)) //which gives an error as the map value is a string not field token

 

Please let me konw how to get the fieldtoken.

 

 

 

iffuiffu

Hi

 

I am also stucked in here...any luck?