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
abhi patilabhi patil 

invalid type : review _c

trigger AccountTriggerDelete on Account (before delete, after  delete, after undelete) {
    
    if (trigger.isbefore){
        if(trigger.isdelete){
            
            //Before deleting account record, retrieve all review records
            // delete review records related to account
            List<review_c> rvlist = [select id, Account_c from review_c where Account_c IN :trigger.old];
            
             delete rvlist;
Best Answer chosen by abhi patil
SwethaSwetha (Salesforce Developers) 
HI Abhi,
If Review is the custom object in your org, its API name should be review__c (notice two underscores) and not review_c(single underscore)

The same applies to custom field Account_c(API name should end with "__c" )

If this information helps, please mark the answer as best. Thank you

All Answers

SwethaSwetha (Salesforce Developers) 
HI Abhi,
If Review is the custom object in your org, its API name should be review__c (notice two underscores) and not review_c(single underscore)

The same applies to custom field Account_c(API name should end with "__c" )

If this information helps, please mark the answer as best. Thank you
This was selected as the best answer
Arun Kumar 1141Arun Kumar 1141


Hi Abhi,

The code snippet you provided is an Apex trigger written in Salesforce. It appears to be a trigger named "AccountTriggerDelete" that is executed before and after the deletion of an Account record. The trigger includes logic to delete associated records of a custom object called "review_c" when an Account is deleted.

The error message "invalid type: review_c" suggests that the Apex compiler cannot find the definition for the "review_c" object. This typically occurs when the object or its corresponding custom object is not defined in the Salesforce org.

To resolve this issue, ensure that you have a custom object named "review_c" defined in your Salesforce org. The object should have the same API name as referenced in the trigger. Also, make sure that the API name is spelled correctly and that the object is accessible in the context of the trigger.

If the "review_c" object is defined as a custom object but the error persists, double-check that the API version of the trigger is compatible with the custom object's API version. If the custom object was recently created or modified, it's possible that the trigger's API version is outdated, preventing it from recognizing the object.

Additionally, verify that the object has the necessary permissions for the user executing the trigger. If the user does not have sufficient privileges to access or delete records of the "review_c" object, it can result in this error.

By addressing these potential issues, you should be able to resolve the "invalid type: review_c" error and execute the trigger successfully.

Hope this will be helpful.
Thanks!

sravani proddatur 10sravani proddatur 10
HI Abhi,

Please check this fields in your code ( Account_c, review_c )...Custom  field  API Name will add __c  at the end ....

If this information helps, please mark the answer as best.
Thank you.