I am trying to do the following:-
1) Declaring the object variables
2) Instantiating the controller3) Instantiating the objects4) Trying to set the Id of the contact object to that of the account related to the opporutnity.5) Invoking the controllers 'Save' Method6) Inserting (or Update?) the contact object to the database
Any help with my approach is greatly appreciated!
public with sharing class NewLeadControllerExtension
{
ApexPages.StandardController controller;
public Opportunity oppt {get; set;}
public Contact cont {get; set;}
public NewLeadControllerExtension(ApexPages.StandardController controller)
{
this.controller = controller;
oppt = (Opportunity)controller.getRecord();
oppt.AccountId.Contact.Id = cont.Id;
}
public PageReference SaveBoth()
{
controller.Save();
insert cont;
return null;
}
}
Many thanks AshishWith the code you mentioned above I am still getting the following error: "MISSING_ARGUMENT, Id not specified in an update call" But if I use the folloing code instead
cont.Id = oppt.Account.Contact.Id
I am recieving the error:
"Invalid foriegn key relationship"The org I am working in has personal accounts enabled - whould this make any difference here?Thanks again for any help here! :)