jweipert - Wednesday, September 5, 2012 4:28 PM:
I am using Aras 9.3 out of the box (no service packs)
We have an ItemType [Parent] with a related Item Type [Child].
The [Child] does not have a Save button on the Form since it is driven by the parent. Just close the [Child] Form window when finished entering a note/message on the Form.
On [Parent] Save, the Child record needs to send an Email Notification via an Automated Workflow.
The problem is that the [Parent] will not save(nor the [Child]) until the workflow associated with the [Child] has completed (or ended). Therefore, the email message has no data since the Query to the database (configured in the email notification) returns no data since the [Child] record has NOT been Saved Yet.
Are we missing something or is it not possible to Save then trigger the Email Notifcation somewhere that can wait for the Save to complete before calling the Email Notification (via an automated step rather than the obvious manual Workflow Activity that currently drives all email notifications after a 'Vote' has been submitted?
* Delaying the Workflow Activity via a Client or Server method is useless since it delays the controlling(outside) event... which is the Save Event.... Save always executes last (in a holding pattern for all workflow & lifecycle events to complete).
Brian - Friday, September 21, 2012 8:48 AM:
Hi John,
I think you could get around the problem by triggering a server method in onAfterAdd/onAfterUpdate to programatically vote for the workflow activity after the save child has completed.
See this wiki post: http://www.aras.comhttp://www.aras.com/Community/wikis/kb/programmatically-vote-for-a-workflow.aspx for details on how to vote for an item in a method.
Hope this helps,
Brian.
MFJames - Wednesday, October 17, 2012 9:50 AM:
Thank you for pointing us (John and myself) in the right direction. Life, of course, is never quite as simple as you expect, but with your nudge we have it working now.
OnAfterAdd suffers the same fate, in that it fires before the data is saved. So the workflow launched at that point still sends empty emails. But by splitting the problem into two parts we have a solution. OnAfterAdd knows that we have created a new instance of [Child], so at that point we use the event to insert a flag into the [Child] item that says "I need to notify somebody about this". Then, on the form that contains all this, we use an OnBeforeUnload to look for the flag. (That is, as the form is about to be closed.) If it finds it, it fires the workflow (and therefore the email) and clears the flag. This event fires after any saves have been completed, so we know that any [Child] items the user has committed are now saved in the database for the email message to find.
This has the added advantage that the users can be as hesitant as they like in creating the perfect [Child], including closing the form (without saving) and re-opening it. It's only after they finally hit "Save" or "Save/Unlock/Close" that anybody is notified of the new [Child].
--
Martin James