
For your reference, i have attached the code
Drawback: My cases assigned to All related opportunities
Code:
trigger CasetoAccountInsert on Case (before insert) {
for(Case record: Trigger.new)
{
List<Opportunity> OpportunityList = [SELECT AccountId, Name FROM Opportunity WHERE Contact_Email__c = :record.SuppliedEmail] ;
if (OpportunityList.size() > 0)
{
record.AccountId = OpportunityList[0].AccountId;
}
}
}
Thanks in Advance
AnuSh
2 réponses
This Answers Community is focused on configuration and design questions. Programmatic questions are best submitted to the developer forums at https://developer.salesforce.com where the forums and participants are geared toward programming troubleshooting and support.