2
votes

I have a question regarding a problem I'm facing. Is there any way I can have a workflow waiting for another workflow to finish (or at least fire a couple of seconds after the first has executed)?

My scenario: I have a workflow waiting until 6 months before contractline expiry date, once it reaches that date, it creates a custom entity and on the cutom entity I have a plugin registerd which creates an opportunity and inserts, an opportunity product line (for the expired contract line).

Problem: The contract can have more than one contractline expiring at the same date, hence the workflow kicks off and creates multiple opportunties, adding each line in one opportunity, which shouldnt happen as I want all contract lines to end up in one opportunity. This doesn't happen too often, but I believe when the worflows execute at exectly the same time, I get this weird behaviour.

Any help would be much appreciated. Thanks.

1
you could create a WF Activity whose job is to search for the related entities and either creates a new related entity or attaches to the existing one if you have a way of predicting something about this related entity.Mike_Matthews_II

1 Answers

1
votes

The approach I would normally take with this would be something like: wait a while, then check a lookup field on a relevant record (the contract line or contract in this case). If not filled in, create a record (Opp in your case) and fill in the lookup to point to it.

Now call a child workflow or just do some steps against the record in the lookup which we know is now filled in one way or the other.

So first WF to hit this sees no Opp, creates one then does stuff to it (eg in a custom workflow assembly).

Second WF gets there and finds Opp already there so uses it.

Problem in you scenario is that you can't update the Contract once it has been invoiced / activated. So you may have to just create the Opportunity in the first place (with a future est close date on), then let your workflows run, wait and use this one when they get there.

If you really don't like that many open Opps, then create a layer between - have a lookup from Contract to a "renewal" custom entity which itself does nothing but hold the Opportunity lookup. Create the renewal when the contract is created (wf or plugin) so that lookup is already populated.