BPM issue Creating an Order from a Quote

(the issue is likely me being fairly new to this :wink:

  • Have a custom field on order detail lines that get’s populated with a value when the line is created.
  • Have a BPM that calls a function to get the value and then uses set field widget to set it in the detail line.

Since the dataset for the BPM is based on BO SalesOrder I have what I need to update the detail lines (this is working for manually creating a new detail line and creating a new detail line by pulling it from the quote)

I’m struggling with doing the same when on the quote form and using “create order from quote” on the actions screen.

I monitored the trace for all the BOs and Methods that occur during the create order from quote. They all have a context/dataset for the Quote BO (logically).

But I want to update each detail line on the order that is being created and the dataset is always specific to the Quote tables so I can’t seem to get the set field widget to do this

thoughts ?

What BO method are you using on SalesOrder (the one that works when a Order Detail is created through the UI)?

And which field in OrderDtl are you updating with the fetched value?

Yes, that is the one, and the detail field I’m updating is a custom field we added.
But the sales order ones are working fine.

The issue I’m having is with my method directive on BO.Quote.CreateOrder, I’m able to call my function to get the value but would like to use a widget step to set the value in the order detail lines

I get that your issue is with Quote.CreateOrder. I wanted to se what you have that works. Which exacts methods are used in the BPM’s that work? And does the CreateOrder method actually result in calling the other methods that are currently working?

There should be a widget that allows you to update the dataset holding the data that will go into the new order. Sorry that I forget the name of it. You might have problems if the CreateOrder method sends all the lines at once (all in one dataset). You may need to make a temp dataset with just the key values (OrderNum, and OrderLine) and your UD value. Then update the native ds, using your temp one to update the OderDtl UD fields.

The methods that work are SalesOrder.OrderDtlGetNewFromQuote and SalesOrder.GetNewOrderDtl.

The Quote.CreateOrder does not call other methods (just my same function that the above methods call)

The Quote.CreateOrder BPM must have a dataset (or sets) with all the values it needs to push to the quote. This should have the OrderDtl UD fields in it to.

I have a Data directive on OrderHed that’s causing the same issue with create order from quote:

Exact Scenario :

  • A quote is created with a Sales Kit
  • Order Manager goes to ‘Create Sales order’
    -Once ‘Create’ is clicked, an Error pops up saying to contact system administrator.
  • Turn off the directive, and repeat steps 2 and 3, the order will be created like normal but without the calculated values at the header level.

After extensive testing with this directive, I’ve found the issue.

In this directive, the goal is to sum up calculated line values and present them in a field on the header level. The values in question are Gross profit values. Each line present on a quote has a GP value, that I then use to sum at the header level to create an estimated total GP for the order. The problem is that the sales kits lines also gets a GP value, which is normally inaccurate and artificially increases the estimated GP on the order if that is included. To avoid this, the following logic was created:

if (OrderHed != null)
{
decimal gpSum = 0;
var OrderLines = Db.OrderDtl.Where(q => q.Company == OrderHed.Company && q.OrderNum == OrderHed.OrderNum && q.KitFlag != “P” );
if (OrderLines.Count() > 0 )
gpSum = OrderLines.Sum(s => s.OrderLineGP_c);

You’ll see that in the var OrderLines, I’ve included KitFlag does not equal P, meaning it will not sum that line with the rest of the lines. Syntax is correct, and logically it makes sense, but the "&& q.KitFlag != “P” is what is stopping the processing of the quote to an order. When this phrase is removed from the logic, quotes with sales kits can be created, and the calculations will occur.

Unfortunately, when this phrase above is removed, it then sums all order lines (included kit parent lines) and shows a much higher value for Estimated Gross profit and gross margin at the header level.