# BPM Sales Order Entry

**URL:** <https://www.epiusers.help/t/bpm-sales-order-entry/37080>\
**Category:** Epicor ERP 10\
**Tags:** e10, epicor\
**Created:** [January 30, 2017, 9:41pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080 "2017-01-30T21:41:35Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShawnLeenerts](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@ShawnLeenerts](https://www.epiusers.help/u/ShawnLeenerts)\
**Post date:** [January 30, 2017, 9:41pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/1 "2017-01-30T21:41:35Z")

</div>

I’m trying to create a BPM using the SalesOrder.Update method that upon saving will check the customer ship to address to see if it’s domestic or international, and then change the Group field (OrderDtl.ProdCode) for all items to match. We have product groups that are different for domestic (i.e., “Install”) and international (i.e., “Install INTL”), so these entries need to align with the ship to address.

The reason for this is if someone enters in a new sales order, then adds a bunch of line items, and then changes the ship to address from domestic to international, or vice-versa, the BPM will check each line item and change them accordingly.

I’ve got the BPM to where it checks the ship to address in ttOrderHed.ShipToAddressList and assigns the OrderNum to a variable. Can’t figure out how to check each line item and update the ProdCode field. I tried using the “Set by Query” feature but can’t get it to work. Does this sound like an impossible task? Any help is appreciated. Thank you for your time!

---

<div class="post-metadata">

**Author:** ![SimsTrak](https://www.epiusers.help/user_avatar/www.epiusers.help/simstrak/32/33313_2.png) [@SimsTrak](https://www.epiusers.help/u/SimsTrak)\
**Post date:** [January 31, 2017, 4:23am UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/2 "2017-01-31T04:23:34Z")

</div>

Shawn,

You’ve really got two issues here.

First, what I would suspect would occur most times, is the Sales Order Header gets set (so the ship-to address is set) prior to any lines being added. In this case, I’d probably put a BPM not on the update, but rather on the POST-PROCESSING when the part number is changed (ChangePartNumMaster) - which is the point where it’s setting the product code on the line - and have it change the product code then. So, as the user adds lines, it is setting the correct product group as they go. This has the added benefit of allowing the system to DEFAULT to a product code - and the user would still be able to change it after the fact if there are exceptions to your rules.

Second, it could be possible that the user gets all the lines added, and after the lines are added, they change the ship-to address to/from domestic/international. This is a different issue, I would likely put together some advanced BPM code (C# for E10) that goes through the order and changes each line. Of course, there’s the added issue that the “ship-to” is on the order, line and release - so you may have to take into consideration if your company ships orders to multiple ship-to addresses. It is possible one line would be domestic, another line international.

Not sure if you can do the first BPM with all canned actions, but the second will definitely need custom code.

Let me know if you have any further questions.

Kevin Simon  
SimsTrak Consulting, LLC

> **[SimsTrak Consulting, LLC](http://simstrak.com/index.html)**
>
> SimsTrak was founded in 2010 by Kevin Simon.  Kevin has logged over 18000 hours working SOLELY on Epicor just this decade, primarily in the areas of Epicor Development, Customizations, Conversions...

---

<div class="post-metadata">

**Author:** ![ShawnLeenerts](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@ShawnLeenerts](https://www.epiusers.help/u/ShawnLeenerts)\
**Post date:** [February 1, 2017, 2:31pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/3 "2017-02-01T14:31:20Z")

</div>

Hey Kevin,

Thank you for the response. I’ve only been working with Epicor for a month or so and have gone through a lot of the embedded and online courses, but even that material doesn’t cover everything. I’ve been working on this off and on for the past few days. The first part of your reply is not an issue, but the second part has me stumped. For my company, we will never ship to multiple locations that would mix domestic and international. That being said, I’ve setup a BPM on the SalesOrder Update method, under Pre-processing where I have a condition that checks if the OrderHed ShipToAddressList field contains “US”. If it does then the OrderNum is set to a variable, and the flow passes to a Custom Code action (see code below). In this action it should go through each record with the OrderNum saved in the variable then change the ProdCode field, which in this case is just TESTING until I can get it to work.

foreach (var ttOrderDtl\_iterator in (from ttOrderDtl\_Row in ttOrderDtl  
where ttOrderDtl\_Row.OrderNum == this.orderNum  
select ttOrderDtl\_Row))  
{  
var ttOrderDtl\_xRow = ttOrderDtl\_iterator;  
ttOrderDtl\_xRow[“ProdCode”] = “TESTING”;  
}

I even put a Show Message action to say the process was complete. I get the message, but when I refresh the order and check the ProdCode field, nothing has changed. At a loss at this point. Thank you for your time and any help you can provide!

---

<div class="post-metadata">

**Author:** ![T11](https://www.epiusers.help/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@T11](https://www.epiusers.help/u/T11)\
**Post date:** [February 1, 2017, 6:44pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/5 "2017-02-01T18:44:17Z")

</div>

> [@ShawnLeenerts](#):
>
> ShipToAddressList field contains “US”. If it does then the OrderNum is set to a variable, and the flow passes to

Did you try putting the message in the foreach loop? The order details you are looking for might not be in the dataset

---

<div class="post-metadata">

**Author:** ![ShawnLeenerts](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@ShawnLeenerts](https://www.epiusers.help/u/ShawnLeenerts)\
**Post date:** [February 1, 2017, 7:40pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/6 "2017-02-01T19:40:46Z")

</div>

Epicor doesn’t like the MessageBox.Show. I tried using System.Windows.Forms, but it didn’t like that either. I will search for other ways to display messages. Thanks!

---

<div class="post-metadata">

**Author:** ![zwilli526](https://www.epiusers.help/user_avatar/www.epiusers.help/zwilli526/32/50966_2.png) [@zwilli526](https://www.epiusers.help/u/zwilli526)\
**Post date:** [February 2, 2017, 3:15am UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/7 "2017-02-02T03:15:32Z")

</div>

Instructions for bpm c# message boxes

[http://erp.ittoolbox.com/groups/technical-functional/epicor-l/epicor-10-bpm-messagebox-or-alternative-for-debugging-5820800](http://erp.ittoolbox.com/groups/technical-functional/epicor-l/epicor-10-bpm-messagebox-or-alternative-for-debugging-5820800)

---

<div class="post-metadata">

**Author:** ![bmgarver](https://www.epiusers.help/user_avatar/www.epiusers.help/bmgarver/32/2867_2.png) [@bmgarver](https://www.epiusers.help/u/bmgarver)\
**Post date:** [February 2, 2017, 2:30pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/8 "2017-02-02T14:30:47Z")

</div>

Use a BPM In-Transaction Data Directive on the OrderHed table Condition on the value of the OrderHed.IntrntlShip field (True or False) and execute the following Custom Code:

```
/* ProdCode */
Erp.Tables.OrderDtl OrderDtl;
foreach (var ttOrderHedRow in ttOrderHed)
{
    foreach (var OrderDtl_iterator in (from OrderDtl_Row in Db.OrderDtl
                                       where OrderDtl_Row.Company == ttOrderHedRow.Company && OrderDtl_Row.OrderNum == ttOrderHedRow.OrderNum
                                       select OrderDtl_Row))
    {
        OrderDtl = OrderDtl_iterator;
        OrderDtl.ProdCode = "TESTING";
	}
}

```

![](https://epiusers.help/uploads/default/original/2X/5/506cfcf20f263e1c33244d6f2a3ddf444461e56b.png)

---

<div class="post-metadata">

**Author:** ![ShawnLeenerts](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@ShawnLeenerts](https://www.epiusers.help/u/ShawnLeenerts)\
**Post date:** [February 2, 2017, 4:17pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/9 "2017-02-02T16:17:18Z")

</div>

Thank you Brian! I had to tweak the code some to get the results we were looking for, but this helped me get where I needed to be. Thanks to all of you who replied trying to help. I hope someday I’ll have enough knowledge that I’ll be able to help people too.

---

<div class="post-metadata">

**Author:** ![SimsTrak](https://www.epiusers.help/user_avatar/www.epiusers.help/simstrak/32/33313_2.png) [@SimsTrak](https://www.epiusers.help/u/SimsTrak)\
**Post date:** [February 2, 2017, 8:24pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/10 "2017-02-02T20:24:17Z")

</div>

I was wondering - when using the Epicor ABL -\> C# converter, it uses the string compare function on testing character fields, versus the ==. So, where you listed:  
where OrderDtl\_Row.Company == ttOrderHedRow.Company  
the converter tool would generate:  
where string.Compare(OrderDtl\_Row.Company, ttOrderHedRow.Company, true) == 0

I know both of these work. Does anyone know if one is inherently better than the other? I guess I’m primarily looking at response - if they’re the same I’d use the “==” as it’s cleaner.

Thanks.  
Kevin

---

<div class="post-metadata">

**Author:** ![ShawnLeenerts](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@ShawnLeenerts](https://www.epiusers.help/u/ShawnLeenerts)\
**Post date:** [February 3, 2017, 4:47pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/11 "2017-02-03T16:47:12Z")

</div>

Hey everyone! I thought I had this solved, but in working through scenarios we found we needed something a little different. I had the BPM set to look for “US” in the ttOrderHed.ShipToAdressList of the updated row on the SalesOrder.Update method, but then we found that if someone added another line item and saved it didn’t check the list.

Basically what I’m needing is this: A user creates a new sales order, places line items on it and saves the record. On the SalesOrder.Update method I need to lookup the ship-to country and then check the product group of each line item to be sure it’s entered correctly (i.e., “Install” for domestic, “Install INTL” for international), and change it accordingly if it’s not. I’ve got the code that looks at each line item and changes the product group as needed (see code below), but I can’t figure out how to lookup the ship-to country.

> Erp.Tables.OrderDtl OrderDtl;  
> foreach (var ttOrderHedRow in ttOrderHed)  
> {  
> foreach (var OrderDtl\_iterator in (from OrderDtl\_Row in Db.OrderDtl  
> where OrderDtl\_Row.Company == ttOrderHedRow.Company  
> && OrderDtl\_Row.OrderNum == ttOrderHedRow.OrderNum  
> select OrderDtl\_Row))  
> {  
> OrderDtl = OrderDtl\_iterator;

> ```
> if (OrderDtl.ProdCode.EndsWith("IN"))
> {
> OrderDtl.ProdCode = OrderDtl.ProdCode.Remove(OrderDtl.ProdCode.Length - 2, 2);
> }
> }
> 
> ```
> 
> }

---

<div class="post-metadata">

**Author:** ![bmgarver](https://www.epiusers.help/user_avatar/www.epiusers.help/bmgarver/32/2867_2.png) [@bmgarver](https://www.epiusers.help/u/bmgarver)\
**Post date:** [February 3, 2017, 5:41pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/12 "2017-02-03T17:41:59Z")

</div>

![](https://epiusers.help/uploads/default/original/2X/1/105ccb01965e662fc9507cb8951d6083cf5fdc91.png)

---

<div class="post-metadata">

**Author:** ![ShawnLeenerts](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@ShawnLeenerts](https://www.epiusers.help/u/ShawnLeenerts)\
**Post date:** [February 3, 2017, 7:31pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/13 "2017-02-03T19:31:18Z")

</div>

Thanks Brian! I think I was over thinking it and trying to come up with custom code to get the ship-to country. Unfortunately, this only returns the default country in the customer table, and not the ship-to country of the sales order. I also did try the same process with the ShipTo table, but didn’t get the desired results either.

 ![](https://epiusers.help/uploads/default/original/2X/4/4df2d5dbabc98d1150e1f3d8b96be1437fcc890b.png)

---

<div class="post-metadata">

**Author:** ![ShawnLeenerts](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@ShawnLeenerts](https://www.epiusers.help/u/ShawnLeenerts)\
**Post date:** [February 3, 2017, 8:11pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/14 "2017-02-03T20:11:56Z")

</div>

I finally got it, I think! I ended up using a Condition that checked the ShipToAdressList custom field of “all rows”, and then moved to the custom code. Everything seems to be working. Thank you all for your time & help!

 ![](https://epiusers.help/uploads/default/original/2X/d/d9f98c99a856ffbb36e8085071dc8fb382d0f416.png)

---

<div class="post-metadata">

**Author:** ![bmgarver](https://www.epiusers.help/user_avatar/www.epiusers.help/bmgarver/32/2867_2.png) [@bmgarver](https://www.epiusers.help/u/bmgarver)\
**Post date:** [February 3, 2017, 8:20pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/15 "2017-02-03T20:20:13Z")

</div>

I see an issue if an international customer contains “US” anywhere in their name, city, state or address.

---

<div class="post-metadata">

**Author:** ![bmgarver](https://www.epiusers.help/user_avatar/www.epiusers.help/bmgarver/32/2867_2.png) [@bmgarver](https://www.epiusers.help/u/bmgarver)\
**Post date:** [February 3, 2017, 8:25pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/16 "2017-02-03T20:25:47Z")

</div>

Consider the following:

Check if the OrderHed.ShipToNum = “”  
 ![](https://epiusers.help/uploads/default/original/2X/f/f494c77855b22b30d0d25f5155d3b763573d00e2.png)

if true check if the Customer.Country = “US”  
 ![](https://epiusers.help/uploads/default/original/2X/f/f20bff72544d85b5efa7c388a422589ffe2a15c5.png)

if false check if the ShipTo.Country = “US”  
 ![](https://epiusers.help/uploads/default/original/2X/b/b8298aac7e7ab6281398b117a7412a25f8609b9c.png)

Run custom code to change ProdCode based on either International or Domestic shipping  
 ![](https://epiusers.help/uploads/default/original/2X/4/4375cd0c7f55941db2810353d96c0b59e48e625d.png)

---

<div class="post-metadata">

**Author:** ![ShawnLeenerts](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@ShawnLeenerts](https://www.epiusers.help/u/ShawnLeenerts)\
**Post date:** [February 3, 2017, 9:03pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/17 "2017-02-03T21:03:09Z")

</div>

I set it up as you showed, with simple messages to say YES if it’s USA and NO if it’s not…

![](https://epiusers.help/uploads/default/original/2X/2/22b6d2e45ed2b22f9a5acc75f0ce73461ad461dd.png)

When I change the ship-to address to Germany and save the record, it still gives me the message of YES…

 ![](https://epiusers.help/uploads/default/original/2X/5/503467fe27f9fc1d80e681a0c11c264ba141bac5.png)

Thanks for the suggestion though!

---

<div class="post-metadata">

**Author:** ![bmgarver](https://www.epiusers.help/user_avatar/www.epiusers.help/bmgarver/32/2867_2.png) [@bmgarver](https://www.epiusers.help/u/bmgarver)\
**Post date:** [February 3, 2017, 9:53pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/18 "2017-02-03T21:53:15Z")

</div>

Based on the logic I presented, count(ShipTo.Country = “USA”) \< 1 would be true and result in Yes as you have shown. Unless you used Count(ShipTo.Country = “USA”) !\< 1 in the query statement

---

<div class="post-metadata">

**Author:** ![ShawnLeenerts](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@ShawnLeenerts](https://www.epiusers.help/u/ShawnLeenerts)\
**Post date:** [February 6, 2017, 3:24pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/19 "2017-02-06T15:24:14Z")

</div>

I have it setup as you showed, with the Count(ShipTo.Country = “USA”) \< 1. When I change the ship to address between domestic and international and save it gives me the correct response. Perfect!

 ![](https://epiusers.help/uploads/default/original/2X/8/861277664599d3b3d5b1363a6aab720ee2aeb810.png)

 ![](https://epiusers.help/uploads/default/original/2X/7/786a4c55182f1bcd71404729446b2f004d36af86.png)

But, when I change something on a line item, say the product group, and then save it fails…

 ![](https://epiusers.help/uploads/default/original/2X/9/9d6dae57a290aa6d1bdd820db7dd94848793d434.png)

---

<div class="post-metadata">

**Author:** ![bmgarver](https://www.epiusers.help/user_avatar/www.epiusers.help/bmgarver/32/2867_2.png) [@bmgarver](https://www.epiusers.help/u/bmgarver)\
**Post date:** [February 6, 2017, 3:44pm UTC](https://www.epiusers.help/t/bpm-sales-order-entry/37080/20 "2017-02-06T15:44:18Z")

</div>

Are you setting up multiple BPMs, one checking for change in the ShipTo and one looking for change in the OrderDtl? If so, verify the logic for determining the country is consistent.
