You need to sign in to do that
Don't have an account?
Abraham kumar 4
Insert record fails
Hi all The below is the area of error , i actually bring contacts to a custom object called event__c and then change these contacts to an other custom object called guest__c with a status associated to the event. now my problem is contacts should be added as guests to multiple events ie)1contact-->Many guests to multiple events. Now contact is getting converted/insert to guest only if it is not part of any event. i want it to convert to guest of an event even if its associated with any other event. how can changes made below to achieve below
Hope Im clear.. Many Thanks
Hope Im clear.. Many Thanks
public void addMembers() { try{ guestList = new List<Guest_New__c>(); set<ID> contactIds = new set<ID>(); for(conWrapper cwrap : conWrapperList){ contactIds.add(cwrap.objContact.id); } map<ID, guest_new__c> contToGuestMap = new map<ID, guest_new__c>(); for(guest_new__C g : [select contact__c from guest_new__c where contact__c = :contactIds]) contToGuestMap.put(g.contact__c, g); for(conWrapper cwrap : conWrapperList){ if(cwrap.checked == true){ Guest_New__c objGuest = contToGuestMap.get(cwrap.objContact.Id); if(objGuest == null){ objGuest = new Guest_New__c(); objGuest.Event__c = EventId; } objGuest.Name = cwrap.Name; objGuest.Email__c = cwrap.Email; objGuest.FirstName__c = cwrap.fName; objGuest.LastName__c = cwrap.lName; objGuest.CompanyOrAccount__c = cwrap.objContact.Account.Name; objGuest.Patch_Controller1__c = cwrap.Patchcontroller; objGuest.Title__c = cwrap.objContact.Title; objGuest.Status__c = statusVal; objGuest.Contact__c = cwrap.objContact.Id; // objGuest.Salutation__c = cwrap.objContact.Name.Salutation; // objGuest.Guest_Address__r.Id = cwrap.objContact.Contact_Address__r.Id; guestList.add(objGuest); } } if(guestList != Null && guestList.size() > 0){ showMsg = true; messageStr = 'You have successfully added '+ guestList.size() + ' member(s).'; ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,messageStr)); system.debug('guestList >>>>>> '+guestList); upsert guestList; } // logic to map contacts to guest }catch(DMLException e){ system.debug('Insertion failed ' + e ); } }
What error exactly you are getting ,Have you checked your logs.