cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Accounts without Opportunities

tandersontph
Observer

Hello all, is there a way to query the number of Opportunities an Account has and then delete the Account if the number is 0 (among other criteria)? We are wanting to automatically delete dormant Accounts using dtv.

1 REPLY 1

JonG_Validity
Validity Team Member
Validity Team Member

Hi @tandersontph, this a great use case - If you don't already have a field with the number of Opportunities listed on the Account or a process in place to do so, you will first want to create a scenario using the Record Count action in the Modify module. You can choose which child object you would like to count & where you want that total to be placed on the Account object as shown below, keeping in mind that you will need a field created to hold that value:

JonG_Validity_0-1703862988825.png

Once you've totalled the amount of Opportunites on the Account, you can then use the Delete module to query and delete any Accounts you see fit. Once the Delete module is opened, you can click the Source dropdown and actually choose your Salesforce environment as a source. Just be sure to use the Select Subset/Filter Records button to query only those records with 0 opportunities or you might have a mess on your hands. Luckily the Delete module lets you preview first! Additionally I recommend using Soft Delete in case you need to Undelete any records from your recycle bin after the fact.

JonG_Validity_1-1703863120269.png

Let me know what you think!

 


Regards,

Jonathan Greenip
Customer Success Manager