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
Steven Wellman 28Steven Wellman 28 

Trigger does not exist error

I'm trying to learn how to write a trigger that calls a class. When trying to deploy I'm getting this error "Trigger does not exist: Trigger"
Here's my Trigger:
trigger MasterOnboardingTrigger on Onboarding__c (
    before insert, after insert, 
    before update, after update, 
    before delete, after delete) {

    if (Trigger.isBefore) {
        if (Trigger.isInsert) {
        // Call class logic here!
        } 
        if (Trigger.isUpdate) {
        // Call class logic here!
        FulfillmentFirst ful = new FulfillmentFirst(Trigger.new);
        }
        if (Trigger.isDelete) {
        // Call class logic here!
        }
    }

    if (Trigger.IsAfter) {
        if (Trigger.isInsert) {
        // Call class logic here!
        } 
        if (Trigger.isUpdate) {
        // Call class logic here!
        }
        if (Trigger.isDelete) {
        // Call class logic here!
        }
    }
}
And here's my class:
public class FulfillmentFirst {
    // This will hold the onboarding record passed by the trigger
    List<Onboarding__c> onbs; 
    

    public FulfillmentFirst (List<Onboarding__c> triggerOnb) {
        onbs  = triggerOnb;
    }

    public void CreateFirstFulfillment(){
        for(Onboarding__c onb : onbs){
            if(onb.Fulfillment_Created__c = false){
                // Engage
                if(onb.Product__c == 'Engage'){
                    Fulfillment__c enFul = new Fulfillment__c();
                    enFul.Name                   = 'Engage First Fulfillment + ' + onb.Account__r.Name;
                    enFul.Status__c            = 'Not Started';
                    enFul.Account__c       = onb.Account__c;
                    enFul.Due_Date__c    = Date.today().addDays(14);
                    enFul.RecordTypeId  = '0121I000000G1dkQAC';
                    insert enFul;
                    onb.Fulfillment_Created__c = true;
                    update onb;
                }

                // Social Ads
                if(onb.Product__c == 'Social Ads'){
                    Fulfillment__c saFul = new Fulfillment__c();
                    saFul.Name                   = 'Social Ads First Fulfillment + ' + onb.Account__r.Name;
                    saFul.Status__c            = 'Not Started';
                    saFul.Account__c       = onb.Account__c;
                    saFul.Due_Date__c   = Date.today().addDays(14);
                    saFul.RecordTypeId = '0121I000000G1dmQAC';
                    insert saFul;
                    onb.Fulfillment_Created__c = true;
                    update onb;
                }

                // Social Posting
                if(onb.Product__c == 'Social Posting'){
                    Fulfillment__c spFul = new Fulfillment__c();
                    spFul.Name                   = 'Social Posting First Fulfillment + ' + onb.Account__r.Name;
                    spFul.Status__c            = 'Not Started';
                    spFul.Account__c       = onb.Account__c;
                    spFul.Due_Date__c   = Date.today().addDays(14);
                    spFul.RecordTypeId = '0121I000000G1doQAC';
                    insert spFul;
                    onb.Fulfillment_Created__c = true;
                    update onb;
                }
            }
        }
    }
}
Any help would be much appreciated.
Best Answer chosen by Steven Wellman 28
Rishab TyagiRishab Tyagi
Hello Steven,

The only possible explanation for your scenario seems to be that you might be having another class named trigger in your org. Please check in your org if this is the case. You can also try to write System.Trigger.new instead of Trigger.new, which will simply route the trigger call to the standard Trigger class instead of any custom-written class.

Hope that answers your question.

All Answers

Raj VakatiRaj Vakati
Do you have any class or trigger with the name "Trigger" ?? Can you share the error screenshot also 
Steven Wellman 28Steven Wellman 28
It's not giving me an error now, but it's not working either. I'm concerned line 7 in my class isn't passing the list through correctly.
Abdul KhatriAbdul Khatri
Can you please share the details of the way you are trying to do the deployment?
Rishab TyagiRishab Tyagi
Hello Steven,

The only possible explanation for your scenario seems to be that you might be having another class named trigger in your org. Please check in your org if this is the case. You can also try to write System.Trigger.new instead of Trigger.new, which will simply route the trigger call to the standard Trigger class instead of any custom-written class.

Hope that answers your question.
This was selected as the best answer
Raj VakatiRaj Vakati
If you have Trigger by name "Trigger" delete that