Skip to main content
Sooriya Kan (achievers) 님이 #Apex에 질문했습니다
I have a map called memberUpdatmap which has some membe'srecord from member object . key is the id 

Map <Id, member__c> memberUpdatmap = new Map <Id, member__c>();

I have an other map  memberUpdatmap2 which has some member records and some record has same id from memberUpdatmap.

but i do not have all the fields for those records from memberUpdatmap .

I need to update all members at one time (one dml statement) .from both map. how do i get all the records from memberUpdatmap  to memberUpdatmap2.

Example: Pls answer this 

Map <Id, member__c> memberMap = new Map <Id, member__c>();

member__c p1 = new member__c();

p1.Id = id;

p1.put('FirstName__c', 'testaug1');

p1.put('coacher__c', '34561');

p1.put('LastName__c', 'check');

memberMap.put(p1.Id ,p1);

Map <Id, member__c> memberUpdateMap2 = new Map <Id, member__c>();

p2.Id = id;

p2.put('FirstName__c', 'testaug1');

p2.put('Employee__c', 'xyZ');

p2.put('LastName__c', 'check');

memberMap2.put(p2.Id ,p2);

p3.Id = id;

p3.put('FirstName__c', 'testaug2');

p3.put('Employee__c', 'xyZ');

p3.put('LastName__c', 'check1');

memberMap2.put(p3.Id ,p3);

but p2.id and p1.id are the same member object(id's are same) and  i need to get p1 with all the fields Employee__c, coacher__c in to memberMap2
답변 2개
  1. 2018년 8월 10일 오후 7:02
    Thanks.but i woulk like to have memberMap2  to get all the records from memberMap2 and memberMap the tricky part  is that someof the ids are same from both map and have differnt fields but i need to get all the fields 

    Or i can have a map let's say memberMap3 which is going to have all the records from memberMap2 and memberMap but if  any of the id exist in both map , i need to get all fields for the id whcih is from both map.Example p2 and p1 are the id so need get the feilds FirstName__c, coacher__c,LastName__c, Employee__c
0/9000