[SalesForce] Visual Flow – Count number of child records

I need to count the number of Assets per Account, in a roll-up summary field. My criteria is: Every time an Asset is created /updated, count number of Assets and store in field 'Number of Assets'.

I believe this can be done using Loops in Visual Workflow but have not yet been able to make this work. Any ideas /material on this?

Best Answer

I'd check out the wizard news, this is where I figured out how to do just that.

The basics are yes you'll need to do a loop. Below is an example I did for counting the number of rewards codes we had left and updated the parent object, Reward with the quantity. Therefore this is the same as with your Account and assets... my Reward = Account, and Reward Code = Asset.

In my overview I have other items I do before and during but I think if you just do the steps I've outlined below that's all you need. You don't have to have a decision so that's why I skip that in my instructions below.

Input: Account ID to be used to lookup related assets to count.

Here is an overview of my flow: enter image description here

1. Get the list of assets for the account: Step 1

3. Loop through list. Must create a loop variable, but will not use. Loop Screenshot

4. this is the way to do a simple N+1 count. Create a counting variable and add to it: Screen shot

5. Now that you have your count, you need to assign that var back to your Account.Asset Count field: screen shot 6. Now just do an update of your account: screen shot

Related Topic