• virat ms kohli
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
I had a scenario wherein the email to case I need to update the case owner as cc of the mail. In cc of the mail, we can have multiple emails right. My requirement is the case owner must be the first mail that was kept in cc.
Example :
From: test@gmail.com
To : hello@gmail.com
cc : digital@gmail.com,harry@gmail.com

In this case i need to get case owner as digital.

For achieving this i had written a trigger

trigger updateCaseOwner on EmailMessage (before insert) {
    List<String> frmadd = new List<String>();   
    List<Id> cseIds = new List<Id>();    
    User con = new User();    
    List<Case> cse = new List<Case>();    
    List<Case> updatedCseList = new List<Case>();
    for(EmailMessage msg : Trigger.new){
        frmadd.add(msg.ccAddress);
        system.debug('frmadd--'+frmadd);
        cseIds.add(msg.parentid);       
    }
    con = [SELECT Id, Email FROM User WHERE Email in:frmadd];   
    system.debug('con---'+con);
    cse = [SELECT ownerid,id, Description, caseNumber FROM Case WHERE Id in: cseIds];
    for(Case cs:cse){
        cs.ownerid = con.id;        
        updatedCseList.add(cs);                
    }
    update updatedCseList;
}

But it was working when i given one mail-in cc. If i given 2 mails. the trigger is not working. Kindly help me in this regard by modifying trigger or giving any other suggestion. 
Hi,

We have 2 objects named seller and invoice. Let's make a month into 2 parts as 1 to 15 and 16 to 31. The seller and invoice have a lookup relationship. If we entering data on the seller object from date 1 to 15 then the invoice date must only be before 1 to 15 that is before month 16 to 31. It should not enter future dates. Or else if we entering data on the seller object from date 16 to 31 then the invoice date must be before 16 to 31 which is the same month 1 to 15. That is a condition so kindly help me in developing validation rule for this. As I was new to salesforce kindly help by writing validation rule for me.

Thanks and Regards,
Virat
Hi,

We have 2 objects named seller and invoice. Let's make a month into 2 parts as 1 to 15 and 16 to 31. The seller and invoice have a lookup relationship. If we entering data on the seller object from date 1 to 15 then the invoice date must only be before 1 to 15 that is before month 16 to 31. It should not enter future dates. Or else if we entering data on the seller object from date 16 to 31 then the invoice date must be before 16 to 31 which is the same month 1 to 15. That is a condition so kindly help me in developing validation rule for this.

Thanks and Regards,
Virat
Hi,

We have 2 objects named seller and invoice. Let's make a month into 2 parts as 1 to 15 and 16 to 31. The seller and invoice have a lookup relationship. If we entering data on the seller object from date 1 to 15 then the invoice date must only be before 1 to 15 that is before month 16 to 31. It should not enter future dates. Or else if we entering data on the seller object from date 16 to 31 then the invoice date must be before 16 to 31 which is the same month 1 to 15. That is a condition so kindly help me in developing validation rule for this. As I was new to salesforce kindly help by writing validation rule for me.

Thanks and Regards,
Virat
Hi,

We have 2 objects named seller and invoice. Let's make a month into 2 parts as 1 to 15 and 16 to 31. The seller and invoice have a lookup relationship. If we entering data on the seller object from date 1 to 15 then the invoice date must only be before 1 to 15 that is before month 16 to 31. It should not enter future dates. Or else if we entering data on the seller object from date 16 to 31 then the invoice date must be before 16 to 31 which is the same month 1 to 15. That is a condition so kindly help me in developing validation rule for this.

Thanks and Regards,
Virat