BPM woes - updating UD field from UD field in another table

,

Struggling with what should be a simple BPM and would appreciate any help. I’ve searched and read through all the posts I could find on the topic.

Goal is to update a UD field on QuoteDtl from a UD field in PriceLstParts when the order quantity on the quote line is changed.

My code in Execute Custom Code is:

foreach (var tt in ttQuoteDtl.Where(tt => tt.Updated() || tt.Added()))
{
  var PriceLstParts = (from pp in Db.PriceLstParts.With(LockHint.UpdLock) where pp.Company == tt.Company && pp.PartNum == tt.PartNum select pp).ToList();
  
  foreach (var x in PriceLstParts)
  {
    if(x!=null)
    {
        x.SetUDField<System.Decimal>("MOQ_c", tt.MOQ_c);  
               
        Db.Validate();
    }
  }

}

When I check syntax, I get an error of ‘QuoteDtlRow’ does not contain a definition for ‘MOQ_c’ and no extension method ‘MOQ_c’ accepting a first argument type of ‘QuoteDtlRow’ could be found

You might try changing this line to
x.SetUDField<System.Decimal>("MOQ_c", tt["MOQ_c"]);
I remember having to do the x["fieldname"] (vs x.fieldname) clause a few times in Epicor 10.1.x, we never did figure out WHY we had to do it sometimes, but it frequently happened with UD fields.

1 Like

Thanks for the suggestion. I recall noticing that in a couple of the posts I read. I changed the line and now get a “unexpected character” for each of the double quotes and “The name “MOQ_c” does not exist in the current context” for each of those.

@jgreenaway I don’t know if they are in the code also, but they look like fancy quotes. you might need to retype them.

2 Likes

Yep, fixed it for y’all.

1 Like

You are referencing the stock dataset from the BO (ttQuoteDtl). That dataset does not have the UD fields built into the classes, because those fields were not there when it was programmed. So in order to be able to reference those, you need to index into them like you showed. It can be confusing sometimes because if you go Db.Table.field then the UD fields show up, but that’s because you are looking directly into the database, and not working through the business object.

You actually could set the UD field that you are trying to set doing x.Moq_c because you are using the DB context to see/set that field and the compiler would be aware of that field. So you actually kind of have what you need backwards. I believe that there should be be a call for get UD field from the tt object like the set UD field if you didn’t want to use the [ ] index that you are using.

Using the non-fancy quotes from @klincecum, and now not getting the errors. Now adjusting the joins to account for multiple price lists. No errors but still not getting data into the QuoteDtl MOQ_c field. Will be working on it more this evening. Really appreciate all the suggestions!

1 Like