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
GabeGabe 

workflow rule on asset object to trigger single email to related contact - compare multiple records

I need to build a workflow rule that does the following:

 

  1. Looks at newly created asset records.
  2. Checks a particular field on the asset record to see if it's false.
  3. Checks a particular field on the related contact record to see if it's false.
  4. Sends a single email to the related contact email if 2 & 3 above are false.

I'm able to do a basic version of this, no problem, but how do I prevent >1 email going to a contact if multiple assets are created simultaneously, as is often the case for us?

 

For example, our most popular SKU (Studio '09 Pro) includes 4 products, which are logged in our SFDC account via the salesforce.com API as 4 separate assets with a common order #, related to the contact (see this screenshot for an example).

 

With the current time-dependent workflow action I'm testing, 4 separate emails are sent, 1 for each asset.

 

So how can I have the workflow rule trigger a single email for each unique order number? Is that possible - to have a workflow rule compare data in multiple asset records vs. looking at a single record's data?

 

It seems like it would be if there were a way to stagger the asset creation a bit, then have the workflow rule check to see if a field had been flagged for a particular order number...

 

Thanks!

werewolfwerewolf

You can't do that with workflow.  Workflow will trigger once for each object.

 

If you are literally adding these assets simultaneously and in bulk (as via the API) then you can do this with an Apex trigger instead.  Apex triggers do fire in bulk, i.e. one trigger will be fired for multiple inserts or updates.

 

If you're just adding them manually one after another, then you'll probably be out of luck, although you might be able to use Cronkit or something to aggregate manual asset adds and send one email for all the assets added in the last 15 minutes or something.

werewolfwerewolf
And even if you could have workflow stagger itself based on an autonumber (which in fact you could do using an autonumber and the MOD function), it still wouldn't help you much, because it would only send an email regarding the asset it's referring to, not the other assets that had been added prior to that point.
GabeGabe

Thanks for the quick reply, werewolf!

 

Yes, we are creating the assets simultaneously via the API. So just to clarify: We could do a time-delayed single email for each unique order #, but it sounds like I'd need to get one of our developers involved to create the Apex trigger as part of the asset creation code we have now via the API?

 

Thanks again.

werewolfwerewolf
Well the Apex trigger is generic, it would apply to all inserts no matter where they came from, but by nature Apex triggers run in bulk where workflow rules do not.
GabeGabe

OK, thanks, werewolf.

 

I guess the key point is that I need to get one of our devs involved since I'm no programmer and haven't done anything with Apex. :)