カスタムオブジェクトを既存のリードオブジェクトに挿入しようとすると、エラーメッセージが表示されます。
List<Lead> leads =[select Id from Lead where Email =:lead.Email ];
if(leads.size()>0)
{
Lead existing_lead = new Lead(Id = leads[0].id);
social_account.Lead__c = existing_lead.Id; //social_account is a custom object that
//has a child relationship to lead.
//ie lead is a parent of social_accounts.
update existing_lead;
insert social_account; //if there is an existing lead with same same email,
//i'd like to insert new social_account to an exsiting lead.
}
このエラーが発生します:
554 System.DmlException:更新に失敗しました。ID00Q3000000WW3isEADの行0の最初の例外。最初のエラー:CANNOT_UPDATE_CONVERTED_LEAD、変換されたリードを参照できません:[]
Class.ProcessContact.handleInboundEmail:行81、列9外部エントリポイント
「updateexisting_lead」をコメントアウトしても、同様のエラーメッセージが表示されます。
554 System.DmlException:挿入に失敗しました。行0の最初の例外。最初のエラー:CANNOT_UPDATE_CONVERTED_LEAD、変換されたリードを参照できません:[Lead__c]
Class.ProcessContact.handleInboundEmail:行82、列9外部エントリポイント
何か提案をいただければ幸いです。
よろしく