BPM for copying comments

,

I have what I believe should be a relatively easy BPM but I can’t quite get the language for some reason. I need to copy the comments from Customer Comments to ShipComments on the Sales Order whenever an order is created for that particular customer. Does anyone have an example of something similar they wouldn’t mind sharing? Thanks

I’d make a Pre-Proc BPM on SalesOrder.ChangeCustomer.

Then use a Set Field widget to set the OrderHed.ShipComment with the expression:

Db.Customer.Where( r =>r.Company == callContextClient.CurrentCompany && r.CustNum == ttOrderHedRow.CustNum).Select( r =>r.Comment ).DefaultIfEmpty("").FirstOrDefault()

edit

Need to add logic so the set field only happens for this customer. Hard coading the CustNum would work (but is undesirable). Better method would be to add a Boolean UD field to Customer table, to indicate if the comments should automatically be copied. Imagine if some entered the following comment under a Customer, “This customer is a huge pain in the ass…” Then that appears on their packer.

Also might want to add logic to see if a ShipComment already exists, so it’s not written over. You could get fancy and use a BPM Form to display the existing comment, what would be added, and the proposed new comment(editable field). Then the user could chose to cancel, accept it, or edit and accept.

2 Likes

Thank you so much! That worked perfectly.