Skip to main content
Anush G a posé une question dans #Customer Service
Subject: I would like to convert Email to case related to recent opportunity ( i have written the code email to case related to opportunity but I would like to assign recent opportunity)

 

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
  1. 24 févr. 2017, 17:50
    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.
0/9000