Sales Order Acknowledgement Email BPM

We have a similar 'BAM', (old version 6.10.541), set up to run off a 'checkbox' put on the VB form.

Our customer service/sales folks are told to Not check the box until all of the lines are entered, and I set a user field in my procedure that assures the email can only go out one time.
Looks like the code for 'sending' is within the 'for each..' block, therefore it will 'fire' for order detail found (?)

I looped thru each order detail, building my email 'body' text, then the code for sending, conditional on whether or not it's ever been 'sent'.
Hi All,

I'm writting a BPM that will send an email to a customer after their sales order has been entered. My BPM works, but if the sales order has two lines, for example, it will send out two emails. Each email will have a seperate sales order line referenced on it. I would like the BPM to send one email with all sales order lines referenced in it. Has anyone done this before? We are running Vantage 803.406A. Below is the code I have so far.

Define Variable Emailed As Logical No-Undo. /* Holds the orignal value of the ttOrderHed.CheckBox03 value. */
Define Variable vFrom as Character No-Undo initial '':U. /* Holds the from email address. */
Define Variable vTo as Character No-Undo initial '':U. /* Holds the send to email address(s). */
Define Variable vCC as Character No-Undo initial '':U. /* Holds CC email address(s). */
Define Variable vBCC as Character No-Undo initial '':U. /* Holds BCC email address. */
Define Variable vSubject as Character No-Undo initial '':U. /* Holds the email subject. */
Define Variable vBody as Character No-Undo initial '':U. /* Holds the message body of the email. */
Define Variable hEmailEx as Handle no-undo. /* Holds the email type. */

For each ttOrderHed where ttOrderHed.RowMod = '' No-Lock.

emailed = ttOrderHed.checkbox03.

End.

For each ttOrderHed Where (ttOrderHed.RowMod = 'A' or ttOrderHed.RowMod = 'U') and ttOrderhed.CheckBox03 = True and LookUp(ttOrderHed.SalesRepList,"AG,RHB,TDY") = 0, Each OrderDtl where OrderDtl.Company = ttOrderHed.Company and OrderDtl.OrderNum = ttOrderHed.OrderNum, First SalesRep where SalesRep.Company = ttOrderHed.Company and SalesRep.SalesRepCode = ttOrderHed.SalesRepList, First CustCnt where CustCnt.Company = ttOrderHed.Company and CustCnt.CustNum = ttOrderHed.CustNum and CustCnt.ShipToNum = ttOrderHed.ShipToNum and CustCnt.ConNum = ttOrderHed.ShpConNum, First ShipVia where ShipVia.Company = ttOrderHed.Company and ShipVia.ShipViaCode = ttOrderHed.ShipViaCode, First ShipTo where ShipTo.Company = ttOrderHed.Company and ShipTo.CustNum = ttOrderHed.CustNum and ShipTo.ShipToNum = ttOrderHed.ShipToNum, First Customer where Customer.Company = ShipTo.Company and Customer.CustNum = ShipTo.CustNum and Customer.ShortChar02 = "US Consumer" No-Lock.

/* Brick Wall message if the ShipTo contact does not have an email address. */
If CustCnt.EMailAddress = "" Then Do:

{lib/PublishEx.i &ExMsg = "'No customer email address found for ' + CustCnt.Name + '. Please enter an email address in the Customer Contact record.'"}

End.

If emailed <> ttOrderHed.CheckBox03 And ttOrderHed.CheckBox03 = True Then Do:

{lib/PublishInfoMsg.i &InfoMsg = "'Send email to customer.'"}
run Bpm/BpmEmail.p persistent set hEmailEx.
assign vFrom = SalesRep.EMailAddress.
assign vTo = CustCnt.EMailAddress.
assign vSubject = 'Thank You for Your Order!'.
assign vBody = "Dear: " + CustCnt.FirstName + "," + CHR(10) + CHR(10)
+ "This email confirms your recent order of a NuStep Product. See order details below:" + CHR(10) + CHR(10)
+ "Order Line " + String(OrderDtl.OrderLine) + " Part No. " + OrderDtl.PartNum + CHR(10).
run SendEmail in hEmailEx (false,CUR-COMP,vFrom,vTo,vCC,vSubject,vBody,"":U).
End.

End.

Thanks,

David Pfiester
Systems Accountant
NuStep, Inc.
734-769-3939 Ext. 150
Put a checkbox on your order form header so that when the user checks it
and then updates the sales order header that the BPM then kicks in.

You can then loop through the ttOrderHed and OrderDtl records to put
together your email and send it out. Before you leave the BPM set the
checkbox back to false.



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of nustepvantage
Sent: Friday, December 17, 2010 8:15 AM
To: vantage@yahoogroups.com
Subject: [Vantage] Sales Order Acknowledgement Email BPM





Hi All,

I'm writting a BPM that will send an email to a customer after their
sales order has been entered. My BPM works, but if the sales order has
two lines, for example, it will send out two emails. Each email will
have a seperate sales order line referenced on it. I would like the BPM
to send one email with all sales order lines referenced in it. Has
anyone done this before? We are running Vantage 803.406A. Below is the
code I have so far.

Define Variable Emailed As Logical No-Undo. /* Holds the orignal value
of the ttOrderHed.CheckBox03 value. */
Define Variable vFrom as Character No-Undo initial '':U. /* Holds the
from email address. */
Define Variable vTo as Character No-Undo initial '':U. /* Holds the send
to email address(s). */
Define Variable vCC as Character No-Undo initial '':U. /* Holds CC email
address(s). */
Define Variable vBCC as Character No-Undo initial '':U. /* Holds BCC
email address. */
Define Variable vSubject as Character No-Undo initial '':U. /* Holds the
email subject. */
Define Variable vBody as Character No-Undo initial '':U. /* Holds the
message body of the email. */
Define Variable hEmailEx as Handle no-undo. /* Holds the email type. */

For each ttOrderHed where ttOrderHed.RowMod = '' No-Lock.

emailed = ttOrderHed.checkbox03.

End.

For each ttOrderHed Where (ttOrderHed.RowMod = 'A' or ttOrderHed.RowMod
= 'U') and ttOrderhed.CheckBox03 = True and
LookUp(ttOrderHed.SalesRepList,"AG,RHB,TDY") = 0, Each OrderDtl where
OrderDtl.Company = ttOrderHed.Company and OrderDtl.OrderNum =
ttOrderHed.OrderNum, First SalesRep where SalesRep.Company =
ttOrderHed.Company and SalesRep.SalesRepCode = ttOrderHed.SalesRepList,
First CustCnt where CustCnt.Company = ttOrderHed.Company and
CustCnt.CustNum = ttOrderHed.CustNum and CustCnt.ShipToNum =
ttOrderHed.ShipToNum and CustCnt.ConNum = ttOrderHed.ShpConNum, First
ShipVia where ShipVia.Company = ttOrderHed.Company and
ShipVia.ShipViaCode = ttOrderHed.ShipViaCode, First ShipTo where
ShipTo.Company = ttOrderHed.Company and ShipTo.CustNum =
ttOrderHed.CustNum and ShipTo.ShipToNum = ttOrderHed.ShipToNum, First
Customer where Customer.Company = ShipTo.Company and Customer.CustNum =
ShipTo.CustNum and Customer.ShortChar02 = "US Consumer" No-Lock.

/* Brick Wall message if the ShipTo contact does not have an email
address. */
If CustCnt.EMailAddress = "" Then Do:

{lib/PublishEx.i &ExMsg = "'No customer email address found for ' +
CustCnt.Name + '. Please enter an email address in the Customer Contact
record.'"}

End.

If emailed <> ttOrderHed.CheckBox03 And ttOrderHed.CheckBox03 = True
Then Do:

{lib/PublishInfoMsg.i &InfoMsg = "'Send email to customer.'"}
run Bpm/BpmEmail.p persistent set hEmailEx.
assign vFrom = SalesRep.EMailAddress.
assign vTo = CustCnt.EMailAddress.
assign vSubject = 'Thank You for Your Order!'.
assign vBody = "Dear: " + CustCnt.FirstName + "," + CHR(10) + CHR(10)
+ "This email confirms your recent order of a NuStep Product. See order
details below:" + CHR(10) + CHR(10)
+ "Order Line " + String(OrderDtl.OrderLine) + " Part No. " +
OrderDtl.PartNum + CHR(10).
run SendEmail in hEmailEx
(false,CUR-COMP,vFrom,vTo,vCC,vSubject,vBody,"":U).
End.

End.

Thanks,

David Pfiester
Systems Accountant
NuStep, Inc.
734-769-3939 Ext. 150





[Non-text portions of this message have been removed]