BPM for SalesRep Push

I’m trying to create a BPM that will pass the Customer level Sales Reps to the Order level.

My only issue with this is that we built UD fields for the customer level sales reps (we needed more than just one) and so I don’t know exactly how to pass the UD field data to the non-UD sales rep fields on the Order level…

So basically I need to create a BPM that grabs Customer fields (one regular field and two UD fields) and passes it to the Order SalesPeople fields.

The fields are -
Customer.SalesRepCode
Customer.SalesRep2_c
Customer.SalesRep2_c

The fields need to be pushed to the following Order level fields (follows same order as above)-
OrderHed.SalesRepCode1
OrderHed.SalesRepCode2
OrderHed.SalesRepCode3

Any help would be greatly appreciated. Thank you.

Something like this should work.

var customer = (from a in this.Db.Customer
where a.CustNum == ‘CustNum’
select new { a.SalesRepCode,a.SalesRep2_c,a.SalesRep3_c }).FirstOrDefault();

var orderHed = (from a in this.Db.OrderHed
where a.OrderNum == 1
select a).FirstOrDefault();

OrderHed.SalesRepCode1 = customer.SalesRepCode;
OrderHed.SalesRepCode2 = customer.SalesRep2_c;
OrderHed.SalesRepCode3 = customer.SalesRep3_c;

1 Like

I’m using the following code (switched the ’ in CustNum)-

var customer = (from a in this.Db.Customer
where a.CustNum == “CustNum”
select new { a.SalesRepCode,a.SalesRep2_c,a.SalesRep3_c }).FirstOrDefault();

var orderHed = (from a in this.Db.OrderHed
where a.OrderNum == 1
select a).FirstOrDefault();

OrderHed.SalesRepCode1 = customer.SalesRepCode;
OrderHed.SalesRepCode2 = customer.SalesRep2_c;
OrderHed.SalesRepCode3 = customer.SalesRep3_c;

But I’m getting the following errors:

Edit -

Is this throwing the last three errors because OrderHed.SalesRepCode1 - 3 are just binded fields on the Order Entry screen? They’re not true DB fields…

You are correct these are not valid db fields. These fields are dumped into the OrderHed.SalesRepList, They are ampersand separated. Also I dont see the other SalesRepFields in the customer table.

Try this->

var customer = (from a in this.Db.Customer
where a.CustNum == ‘CustNum’
select new { a.SalesRepCode}).FirstOrDefault();

var orderHed = (from a in this.Db.OrderHed
where a.OrderNum == 1
select a).FirstOrDefault();

OrderHed.SalesRepList = customer.SalesRepCode;

I tried that (but switched where a.CustNum == ‘CustNum’ to read like where a.CustNum == “CustNum” - otherwise I was getting an error about the characters being too literal or something similar…)

Now I’m getting the following errors -

Edit - I just noticed that you said you didn’t see the other SalesRepFields on the customer table - and that’s just because we have those two fields as UD fields on the Customer table in our environment.

Use Data Directive : OrderHed

Erp.Tables.Customer Customer;

var ttOrderHed_xRow = (from ttOrderHed_Row in ttOrderHed
where ttOrderHed_Row.RowMod == IceRow.ROWSTATE_ADDED || ttOrderHed_Row.RowMod == IceRow.ROWSTATE_UPDATED
select ttOrderHed_Row).FirstOrDefault();

if (ttOrderHed_xRow != null)
{

       Customer = (from Customer_Row in Db.Customer
            where Customer_Row.CustNum == ttOrderHed_xRow.CustNum         
               && Customer_Row.Company == Session.CompanyID     
                select Customer_Row).FirstOrDefault();

       if (Customer != null)
        {
                ttOrderHed_xRow["SalesRepCode1"] = Customer.SalesRepCode;
         
          }             

}
1 Like

That was exactly it! Thank you very much!!

Now I just need to get the UD fields + Order.SalesRepCode2 - 3 to work which should be easy…

I added the fields like so -

   if (Customer != null)
    {
                                                ttOrderHed_xRow["SalesRepCode1"] = Customer.SalesRepCode;
  						ttOrderHed_xRow["SalesRepCode2"] = Customer.SalesRep2_c;
  						ttOrderHed_xRow["SalesRepCode3"] = Customer.SalesRep3_c;
     
      }   

And for some reason it doesn’t add the SalesRepCode2 and 3, it only adds the 1st one… Any ideas?

1 Like

You need to add the other two ids to the same filed

ttOrderHed_xRow[“SalesRepCode1”] = Customer.SalesRepCode + “~” + Customer.SalesRep2_c + “~” + Customer.SalesRep3_c

1 Like

Perfect. I just needed to change the “SalesRepCode1” to “SalesRepList” and it worked… Thank you David and Joseph - I appreciate your help!!

Is there anyway I can get SalesRep from Customer but for Copy Sales Order method instead of creating new sales order?