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
Rahul Jain 199Rahul Jain 199 

How to map salesforce custom object's fields with third party app's fields?

Hello Everyone,

I need to map some custom object fields with some third party app's field.And then insert the value in salesforce selected object's fields

Apex code:

public static  void customObjectFields(String SalesforceField, String selectedThirdAppField){
        List < string > ThirdAppField = new list < string > {'Name','Phone','Email','Address'};  
        customObject newcustomObject = new customObject();
        SObjectType objTokencustomObject = Schema.getGlobalDescribe().get('customObject');
        DescribeSObjectResult objDefcustomObject = objTokencustomObject.getDescribe();
        Map<String, SObjectField> fieldscustomObject = objDefcustomObject.fields.getMap(); 
        Set<String> fieldSetcustomObject = fieldscustomObject.keySet();
        for(String s:fieldSetcustomObject)
        {
            SObjectField fieldToken = fieldscustomObject.get(s);
            DescribeFieldResult selectedField = fieldToken.getDescribe();
            if(SalesforceField == selectedField.getName()) {
           /*    
                for(list<string> comparefields : ThirdAppField ){
                    if(selectedThirdAppField === ThirdAppField){
                        JSONParser parser = JSON.createParser(response.getBody());
                        // Parsing of string      product_type tags /Variants price sku weight weight_unit created_at
                        while(parser.nextToken()!= null) { 
                            if(parser.getCurrentToken() == JSONToken.FIELD_NAME) {
                                parser.nextValue();
                                //here the newcustomObject field is map with shopify field 
                                if(parser.getCurrentName() == selectedThirdAppField) {   // here find the field from json response
                                    newcustomObject.SalesforceField = parser.getText(); // here insert the value in selected salesforce field 
                                    system.debug('prod.Name '+prod.Name);
                                }
                            }    
                        }
                    }
                }
            */
                system.debug('SalesforceField : '+selectedField.getName());
            }
        }
    }

Any help or suggestion will be appreciated.