You need to sign in to do that
Don't have an account?
palukuru sfdc
how to set the value to parent lookup field on child field from anonymous window?
Hi Can someone explain how to set the lookup (from account name value) to conatct name when creating contact from anonymous window.
List<contact> contactToSave = new List<contact> ();
Contact cont = new Contact();
Account acctRef = new Account(name='University of Arizona'); // need to set this name to contact which I'm creating below. Account name already available on org
cont.FirstName='Test1';
cont.LastName='Test2';
cont.Department='Finance';
cont.name=actRef;
contactToSave.add(cont);
insert contactToSave;
please explain how this works...
List<contact> contactToSave = new List<contact> ();
Contact cont = new Contact();
Account acctRef = new Account(name='University of Arizona'); // need to set this name to contact which I'm creating below. Account name already available on org
cont.FirstName='Test1';
cont.LastName='Test2';
cont.Department='Finance';
cont.name=actRef;
contactToSave.add(cont);
insert contactToSave;
please explain how this works...
I think you are trying to create contacts for some existing accounts. You can do that by -
Please accept my solution as Best Answer if my reply is helpful.
All Answers
Hi Palukuru,
Contact.Name field is consist of 3 different fields Salutation+FirstName+LastName.
Contact con = new Contact();
con.FirstName = 'Palukuru';
con.LastName = 'SFDC';
insert con;
List<Contact> conList = [Select Name from contact where LastName = 'SFDC'];
System.debug(conList);
You will get (Contact:{Name=Palukuru SFDC, Id=0032800000n3cG9AAI})
https://success.salesforce.com/ideaView?id=08730000000BqVVAA0
I think you are trying to create contacts for some existing accounts. You can do that by -
Please accept my solution as Best Answer if my reply is helpful.