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
Anonymous DeveloperAnonymous Developer 

Question regarding Mapping

How do I map Contact Id to contact staging object contact Id field?
Best Answer chosen by Anonymous Developer
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

I have added the answer to the below question. This question seems to be duplicate.

https://developer.salesforce.com/forums/ForumsMain?id=9062I000000UhSx

Can you close this thread by marking this as best answer so it avoids duplicate efforts for others.

Thanks,
 

All Answers

mukesh guptamukesh gupta
Hi,

As per my understanding Contact is Look up on Contact_Staging__c object,

Please check Relationship name of Contact_Staging__c , i am assuming Contact_Stagings__r
List<Contact> conList  = New  List<Contact>();
Map<Id, List<Contact_Staging__c>>  conMap = new Map<Id,List<Contact_Staging__c>>();
 
conList = [ Select id,(SELECT AS_Contact_Id__c  FROM Contact_Stagings__r) From Contact];

for(Contact con : conList){
  for (Contact_Staging__c cs : Contact_Stagings__r ){
     if(conMap.containsKey(con.Id)){
         conMap.get(con.Id).add(cs)
     } else{
            conMap.put(con.Id, new List<Contact_Staging__c>{cs})

    }
  }
   
  }  


}



if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

 
Anonymous DeveloperAnonymous Developer

Hello mukesh,

both fields have no relationship to one another so this codwon'tnt work

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

I have added the answer to the below question. This question seems to be duplicate.

https://developer.salesforce.com/forums/ForumsMain?id=9062I000000UhSx

Can you close this thread by marking this as best answer so it avoids duplicate efforts for others.

Thanks,
 
This was selected as the best answer