• Devon Sacks
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I currenlty have a trigger that when someone uses an Objecct button to send an email the Trigger updates the a custom field in the Case Object.
I have yet to write a script for email so I am not sure on this one. I have other triggers that after that field gets updated they update custom objects attached to the Case. Currently after sending an email they manually check the box (sometimes they forget so I want this automated).

Please see below current Trigger code.

trigger UpdateCaseEmail on EmailMessage (after insert)
{
    set<Id> caseIds= new Set<Id>();
    for(EmailMessage rmaEmail:Trigger.new)
    {
        caseIds.add(rmaEmail.ParentID);
    }

    // Find all cases related to the e-mail that just got sent and that have not
    // had their RMA task set yet.
    List<Case> csList = new List<Case>();
    for(ID thisEmailParentId : caseIds)
    {
        csList.add([SELECT Update_RMA_Task__c, CaseNumber, Id 
                    FROM Case 
                    WHERE Update_RMA_Task__c = False 
                    AND id = :thisEmailParentId]);
    }

    // Modify the cases to meet the business rule
    for(Case cs : csList)
    {
        cs.Update_RMA_Task__c = True;
    }
    
    // Send our updates back to Salesforce
    if(csList.size() > 0)
    {
        update csList;
    }
}
 
The issue that I'm facing started a month and half ago. Every time one of our org user creates an opportunity, another prospection opp is automatically created. The way it worked before was, we have a Clone automatically checkbox and its value is defaulted to checked. If the user unchecked this box, the prospecting opp would not be created. And now if we check or uncheck this checkbox, the prospecting opp is created anyways.
I checked the triggers that creates the prospecting opp and found the block of code that creates the prospecting opp when the trigger is fired. On the Sandbox, when I comment that line of code and create an opportunity for testing, no matter if I check or uncheck the Clone automatically checkbox, it doesn't create the prospecting opp. And as soon as I go back to the trigger code and uncomment that line, it creates a prospecting opp if I uncheck the checkbox.
So what I decided to do is to comment the one line of code, deploy the change from Sandbox to Production, and then hide the field from the users' profiles but the deployment failed twice.
Errors I'm getting are:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ContactChangeAfter: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Individual Contact Record Type: this ID value isn't valid for the user: : [RecordTypeId] Trigger.ContactChangeAfter: line 16, column 1
Stack Trace: Class.CampaignWebServices.Test_Campaign_Dedupe: line 81, column 1

System.Exception: Assertion Failed
Stack Trace: Class.OppClone.TestCloneOrgOpp: line 113, column 1

Can you please guide me to solve this issue?

Thanks,

 
I currenlty have a trigger that when someone uses an Objecct button to send an email the Trigger updates the a custom field in the Case Object.
I have yet to write a script for email so I am not sure on this one. I have other triggers that after that field gets updated they update custom objects attached to the Case. Currently after sending an email they manually check the box (sometimes they forget so I want this automated).

Please see below current Trigger code.

trigger UpdateCaseEmail on EmailMessage (after insert)
{
    set<Id> caseIds= new Set<Id>();
    for(EmailMessage rmaEmail:Trigger.new)
    {
        caseIds.add(rmaEmail.ParentID);
    }

    // Find all cases related to the e-mail that just got sent and that have not
    // had their RMA task set yet.
    List<Case> csList = new List<Case>();
    for(ID thisEmailParentId : caseIds)
    {
        csList.add([SELECT Update_RMA_Task__c, CaseNumber, Id 
                    FROM Case 
                    WHERE Update_RMA_Task__c = False 
                    AND id = :thisEmailParentId]);
    }

    // Modify the cases to meet the business rule
    for(Case cs : csList)
    {
        cs.Update_RMA_Task__c = True;
    }
    
    // Send our updates back to Salesforce
    if(csList.size() > 0)
    {
        update csList;
    }
}
 
I am trying to figure out how to create a link or button on the custom visualforce pages that override the SF default home pages for Contacts, Accounts, and Leads. The visualforce home pages are just an extended list of all records in that object since my users were getting confused by the original default home page.  

We just got XMM (Extended Mail Merge) enabled in our org, and the only way to get to it seems to be via the default home page- but we don't use those.  I'd like to find a way to put a button or link on the visualforce home page- or at least provide some way for my users to be able to get to it. Anyone have any thoughts or know anything about this?  Any comments are appreciated!