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
sreenathsreenath 

How to Delete records in standard object

Hi supporters,

 

                  Help me  how to delete all records once in account object which are related to opp. also throw query.

MandyKoolMandyKool

From Your post its bit confusing.. which records you want to delete?

 

 

 

 

sreenathsreenath

HI Kulkarni,

                  Suppose  In account object i have 100 records, some records are related to opp. "closed won" value. I need to delete all account records  completely through query. But, i am getting FATAL ERROR & message as you can't delete closed won records. How to delete all account records through query.

marioluisscmarioluissc

You have delete all Opportunitys before.

 

Then, click in your name>>System Log and execute this script bellow:

 

Opportunity[] opp = [select id from Opportunity];

delete opp;

Account[] acc =  [select id from Account];

delete acc;

CLKCLK

some correction otherwise it will clear all opp & account records.

 

Opportunity[] opp = [select id from Opportunity where your Filter];

Set<id> setId = All Opportunity Id

delete opp;

Account[] acc =  [select id from Account where id in; SetId];

delete acc;