12-28-2023 10:04 AM
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.
12-29-2023 07:20 AM
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:
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.
Let me know what you think!
Get industry news, expert insights, strategies, and hot tips, served up fresh every week.
Visit the Validity blog