BPM for SalesRep Push


(Caleb) #1

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.


(David Penn) #2

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;


(Caleb) #3

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…


(David Penn) #4

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;


(Caleb) #5

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.


(Joseph Brifo) #6

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;
         
          }             

}

(Caleb) #7

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?


(David Penn) #8

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

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


(Caleb) #9

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