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
MPetersenMPetersen 

Trigger - Help with Invalid Type

Hello,

I've recently started working with triggers and I seem to be having problems with custom objects.  I've tried this a few different ways, but I get either Invalid Type(what this is getting now) or Invalid sObject if I try to query SFDC_Bug_c.  

 

Any help you could give me would be greatly appreciated.

 

Thanks,

 

 

trigger SendToBug on Case (before update) {
   
    for(Case c : Trigger.new){
        if(c.Reason == 'Bug')   
            SDFC_Bug_c b = new SDFC_Bug_c(Status_c='Open', Priority_c='P3-Medium', Problem_Description_c = c.Description);
            insert b;
           
    }
}

Best Answer chosen by Admin (Salesforce Developers) 
aalbertaalbert

Well, I dont know your custom object definitions, but is this mispelled: SDFC_Bug__c? Should it be SFDC_Bug__c?

You can verify by using the Force.com IDE Schema Browser (open up the salesforce.schema icon in your Force.com IDE Project)

 

 

All Answers

aalbertaalbert

Try two underscores, SDFC_Bug__c

 

Also, I suggest not inserting the new SDFC_Bug__c record within the For Loop. instead I would add the record to a List or Collection and then after the FOR loop completes, do a single insert of the List. Much more efficient and scalable. 

MPetersenMPetersen

Thanks, aalbert.  Unfortunately I am still getting the same error with two underscores(SDFC_Bug__c). 

 

I see what you're saying about the For loop also.

 

Save error: Invalid type: SDFC_Bug__c 

aalbertaalbert

Well, I dont know your custom object definitions, but is this mispelled: SDFC_Bug__c? Should it be SFDC_Bug__c?

You can verify by using the Force.com IDE Schema Browser (open up the salesforce.schema icon in your Force.com IDE Project)

 

 

This was selected as the best answer
MPetersenMPetersen

Thanks so much.  Sorry for my Dyslexia! That was exactly what it was.  WOW!!!

 

Thanks again.