function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Barry Taylor SwishCleanBarry Taylor SwishClean 

Trigger for Auto Case Creation - Based on Field Update in Contact Record

Hello,

I am rather new to the Apex Programming world and I am trying to create a trigger that would automatically create a new case based on a a field being updated by a user or users.

Our specific situation is that we have an integration with a marketing automation tool called Hubspot and with in that program a customer could request for example a current catalogue, we have a custom field in salesforce.com under the Contact Object called "Catalogue Requested/Delivered" that is updated from the hubspot integration.

What I would like to do is create a case so that our internal customer care team can follow up with that request and ensure that the request was completed.

Where I am looking for some help or direction is I am getting the following error "Error: Compile Error: Expression cannot be assigned at line -1 column -1" and I am not sure where to look or how to fix this issue.

I have attached my currrent code, Thank you for your help.

APEX CONTACT TRIGGER

trigger AutoCreateCase on Contact (after update) {

    List<Case> CaseList = new List<Case>();
   
    for(Contact Ct : Trigger.New){
        if(Contact.Catalogue_Requested_Delivered__c = 'True') {
            CaseList.add(new Case(
            AccountID = Ct.AccountID,
            Type = 'Hubspot Request',
            Origin = 'Auto Generated'
            ));
        }
       
    insert CaseList;
           
   
    } 

}
Sonam_SFDCSonam_SFDC
LIne: if(Contact.Catalogue_Requested_Delivered__c = 'True')

The above line is an assignment - it should rather be:
if(Contact.Catalogue_Requested_Delivered__c == 'True')