You need to sign in to do that
Don't have an account?
Dbjensen
How to assign Ids from SQOL
Hello - I need help adding Account Ids to Contacts. I tried using a map but I don't have any matching keySet that will return the Id. Can I add the Ids to a list and then assign the Id from the list to a updateCt.AccountId? If so, how can I do this without writing a different class?
//Query newly created Account List <Account> insertedAcct = [SELECT Id FROM Account WHERE Id =:insertAccounts]; //Query contact that needs the new Account Id List <Contact> indClientIdList = [SELECT Id, AccountId FROM Contact WHERE Id = :clientIdList]; if(indClientIdList.size() > 0){ for(Contact updateCT : indClientIdList){ updateCt.AccountId = NEW ACCOUNT Id HERE ); } }
For example if you have the same phone as the account in the contact you could do something like this.
Try using something in common, you need a way to know which contact goes with which account.
If it helps please like and if it solves your issue please mark as correct as it may help others.
good luck!
All Answers
For example if you have the same phone as the account in the contact you could do something like this.
Try using something in common, you need a way to know which contact goes with which account.
If it helps please like and if it solves your issue please mark as correct as it may help others.
good luck!
Hi,
I want to add one more thing in the above solution, which is the null pointer exception. There is a possibility that when you execute this accountIdMap.get(updateCT.Phone) maybe that phone number of contact not in the map key and you are trying to get its value, which results in a null pointer exception.so you have to handle it here: (I hope it helps you.)
Thanks for the info, Jitendra. I appreciate the help.