Skip to main content
added 417 characters in body
Source Link
Anu
  • 3.9k
  • 17
  • 78
  • 135

I have a custom setting where I have fields api name and getting the field api name and use with sObject. At that time I am getting error cannot use string with the sObject. How can I convert the string to a sObjectField or is there any other way to do it. my code

 Map<String, SObjectField> fieldMap = SObjectType.CVSR__Visit__c.fields.getMap();

    for(String fieldName : map_customSet.keyset()){
    
        system.debug('field map ' + fieldMap.get(fieldName));
        SObjectField sObjfieldName = fieldMap.get(fieldName);
        
        //system.debug('Visit Field ' + v.sObjfieldName );
        
    
    }

I have a custom setting where I have fields api name and getting the field api name and use with sObject. At that time I am getting error cannot use string with the sObject. How can I convert the string to a sObjectField or is there any other way to do it.

I have a custom setting where I have fields api name and getting the field api name and use with sObject. At that time I am getting error cannot use string with the sObject. How can I convert the string to a sObjectField or is there any other way to do it. my code

 Map<String, SObjectField> fieldMap = SObjectType.CVSR__Visit__c.fields.getMap();

    for(String fieldName : map_customSet.keyset()){
    
        system.debug('field map ' + fieldMap.get(fieldName));
        SObjectField sObjfieldName = fieldMap.get(fieldName);
        
        //system.debug('Visit Field ' + v.sObjfieldName );
        
    
    }
Source Link
Anu
  • 3.9k
  • 17
  • 78
  • 135

convert string to sObjectfield type

I have a custom setting where I have fields api name and getting the field api name and use with sObject. At that time I am getting error cannot use string with the sObject. How can I convert the string to a sObjectField or is there any other way to do it.