Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (13.1k points)

While performing the CRUD operation, I have checked the delete permission before deleting a record, but it still shows CRUD Delete Issue. Herewith I have attached my code. Can anyone help me with this?

if(Schema.SobjectType.Tracking_path__c.isdeletable())

            {

                Delete tpList;

            }    

            else

            {

                ApexPages.addMessage(new  ApexPages.message(ApexPages.severity.FATAL, system.label.delete_access)); 

                return null; 

            } 

1 Answer

0 votes
by (26.7k points)

To fix this issue you can modify your code with the below code:

List<CustomObject__c> listOfCustomObject = [Select Fields from CustomObject__c];

if(CustomObject__c.sObjectType.getDescribe().isDeletable()){

    delete listOfCustomObject;

 }   

I hope this will work.

Want to become a Salesforce expert?  join salesforce lightning training now!!

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 4, 2021 in Salesforce by Sudhir_1997 (55.6k points)
0 votes
1 answer

Browse Categories

...