Method Directive GetByID for UD table failing

Good afternoon,
I have sidestepped the CRM module by adding a “WonLine” field to Quote Entry. At first I tried to add it to the QuoteDtl table, but all the Epimagic was stopping me up. So I added the field in UD07.
UD07.Key1 = QuoteNum
UD07.Key2 = QuoteLine
UD07.Checkbox01 = Won Line Status

I have a button on the Quote Entry form that just adds a record to the UD07 table along with the associated keys. I also added a checkbox on the form to show when it has been checked.

This all works great! Now I am trying to pop a warning to the person entering a sales order line from a quote if the line has not been “won”. I am creating the warning in pre-processing for the method SalesOrder.CreateLineMiscChargesFromQuote.

This seems like the right method, but when I do a UD07 get by ID the whole thing fails if there are no records. I would think my if widget would catch that.

I want the method to work even if there are no records in UD07. But if there is not a record that matches quote and line, then pop a warning to the user.
It seems like it is failing with the error on getbyid.
What am I missing here?
Thanks for your time!

I’d just write a LINQ query in your SO BPM that does the lookup. GetByID pulls in a lot more data than you need.

Sample (I have not tested this, but this is the gist of it)

Db.UD07.Any(ud => ud.Company == company &&
                ud.Key1 == quoteNum &&
                ud.Key2 == quoteLn &&
                ud.CheckBox01  == true)

Should return true only if it finds a record with the corresponding quote, line, and checkbox checked. Otherwise, it will return false. Adjust the logic as needed. You can add or omit the Key3-5 fields since you aren’t actually using them.

1 Like

This sounds simple enough. But I am not sure what you mean. I have to choose a method to write my BPM on. Are you suggesting a route other than method directives?

You said you’re adding a BPM to SalesOrder.CreateLineMiscChargesFromQuote. Try it there.

All this is doing is taking some parameters from your BPM and doing a query. You can call this from any point in the SO process where you have the quote# and ln available to pass along.

Sorry, I guess that is not enough for me to go on. If I put that snippet into a custom code block, what do I do with it? I have no syntax errors with this snippet:


Db.UD07.Any(ud =>
                ud.Key1 == myQuote &&
                ud.Key2 == myLine &&
                ud.CheckBox01  == true);

I’d probably stick that code in one of these:

image

“Valid” is a misnomer. If your code returns true, the BPM will follow the true path on the condition block. If it returns false, it will go down the false path.

Add “return” to the beginning of the code snippet BTW.

1 Like

This works great! Thank you @jtownsend!
I made the condition code:

 return Db.UD07.Any(ud =>
                ud.Key1 == ipQuoteNum.ToString() &&
                ud.Key2 == ipQuoteLine.ToString() &&
                ud.CheckBox01  == true);

On False I show the user a warning (then complete the method), on True, I just complete the method. Thank you!!!

1 Like