+ Start a Discussion
rajesh k 10rajesh k 10 

Using FieldDescribeResult How to add account custom fields to Contact custom Fields without hardcoding?

Hi,
          Using FieldDescribeResult How to add account custom fields to Contact custom Fields without hardcoding?

 
pconpcon
Can you please expand on what you are trying to accomplish?  Are you attempting to aslo get the fields from the Account objects?
rajesh k 10rajesh k 10
Hi,

    I try to below code for add person account custom field values to Contact with out hard coding but in person account custom fields end with __p and contact custom fields end with __c.

 SObject contact;
Account account;
            
            for(Schema.SObjectField objField : Schema.getGlobalDescribe().get('Account').getDescribe().fields.getMap().values())
              {
                if(objField.getDescribe().getName().endsWith('__pc'))
                {
                contact.put(objField.getDescribe().getName(), account.get(objField.getDescribe().getName()));
                }
              }

How to add person account custom field(Metadata fields) values to contact custom fields(Metadata fields)without hard coding?

please help me..