Change OrderDtl fields with BAQ

Hi all!

I’m trying to do this:
In the QuoteDtl I have 2 fields (for every line) L and H. Now when I create an Order from that Quote (Actions -> Quote -> Create Sales Order), I need that those two field will be transported in the corresponding line (the fields L and H are present in the OrderDtl too).

I created a BAQ that with the OrderNum it will give me the PartNum of every line of the order + the L and H fields of the same Part from the QuoteDtl + the Line (that is the same for the OrderDtl and QuoteDtl. It will serve for finding the correct line in the OrderDtl to put the 2 fields).

Now I need to put those 2 fields in the corresponding line of the Orderdtl but here I am stuck.
I am in BPM “SalesOrder.GetByID” - PostProcessing in which i recall the BAQ

Code of my BPM so far:

Ice.Contracts.DynamicQuerySvcContract boDynamicQuery = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.DynamicQuerySvcContract>(Db);

Ice.Tablesets.QueryExecutionTableset dsQueryExecution = new QueryExecutionTableset();
 
int numberOfRows = 0;


ExecutionParameterRow drRow = new ExecutionParameterRow();
   drRow.ParameterID = "OrderNum";  // name of parameter from BAQ
   drRow.ParameterValue = OrderNum.ToString();
   drRow.ValueType = "int";
   drRow.IsEmpty = false;
   drRow.SysRowID = Guid.NewGuid();
   drRow.RowMod = "A";
dsQueryExecution.ExecutionParameter.Add(drRow);


DataSet GetFields = boDynamicQuery.ExecuteByID("GetOrderLines", dsQueryExecution);


foreach (var tables in GetFields.Tables[0].Rows)
{
  numberOfRows += 1;
}

this.PublishInfoMessage("Number of rows: " + numberOfRows.ToString(), Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");

for (int i = 0; i <= (numberOfRows-1); i++)
{
  this.PublishInfoMessage("PartNum: " + GetFields.Tables[0].Rows[i][0] + "\n L: " + GetFields.Tables[0].Rows[i][1] + "\n L: " + GetFields.Tables[0].Rows[i][2] + "\n Line: " + GetFields.Tables[0].Rows[i][6], Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}

Can anyone help me please?
Thanks!

Is it safe to assume this is being put in a BPM, or am I missing something?

EDIT: Just saw your edit.

Yeah sorry I forgot to mention it. I updated the previous post

There are two BPMs that need to be written. One for “pushing” a Quote to an Order (when this is done from within Quote Entry). And one for “pulling” a Quote into an Order (when this is done from within Order Entry).

Edit

The BO and methods are:

  • Quote.CreateOrder
  • SalesOrder.CreateOrderFromQuote

I only need to pull info from the Quote to the Order.
I create the Order from the Quote and the Order is already populated with the lines from the Quote except for those two fields

I found a similar solution the other day that worked for me in a similar scenario (looks like it’s got some extra code you won’t need since you’re using a baq). You should be able to do it pretty easily in a in-trans data directive though on the OrderDtl table (check for added row in if block). Something like the following should work in a data directive, but I haven’t tested it.

ttOrderDtl.L = yourBAQpulledValue

So you want the values in each QuoteDtl.L and QuoteDtl.H of the quote to fill the values in OrderDtl.L and OrderDtl.H, when the “Create Order” action is done in Quote Entry?

If so… you need to use Quote.CreateOrder

Not neccessarly when I create the order.
But when I open an Order I want that it (if it’s created by a Quote) search for those two values for every line and match them.
I don’t know if I’m explaining correctly

So the Order might already exist, and when it’s loaded, you want to make sure that L &H on the order match L & H from the quote?

Yes exactly

Does your user need to know when they’ve been changed? Or can it happen silently in the background?

And is it okay if they change on the order ANY time the order line info is fetched? This could cause issues if someone changes L&H on the Quote, and then something like Packer entry fetches those order lines - triggering the check (and possibly updating them)

“Does your user need to know when they’ve been changed? Or can it happen silently in the background?”

Yes it can happen silently.

“And is it okay if they change on the order ANY time the order line info is fetched?..”

Yeah it’s okay, thanks!

It can be done with no code - just using one Update Table by Query widget

The sample below copies the QuoteDtl.JobComment to the OrderDtl.OrderComment, whenever SalesOrder.GetByID fires

qry1:
Phrase Build
image

Display Fields

configured mapping

3 Likes

And someone will chime in about how linking to temp tables.can cause performance issues. I’d have mentioned the better way, but forget how to do it. :frowning:

I tried to do what you wrote before (adding both H&L to the query and mapping) but it does not work :confused:.

One more thing… You will actually need a second widget.

What I showed in Post #13 would make the Quote Info show in the Order Entry UI, but wouldn’t actually commit it, unless the order was saved in the UI. To make it autmatically save, add an Invoke BO Method widget to invoke an update method.

image

I added the BO Method but it’s the same

Here’s a GIF of it working for me.

  1. It shows me switching between two orders that were made from quotes, and that the Sales Order Comment is blank on both orders
  2. I then enter something in the Job Comment on the quote and save.
  3. I then go back to the Order Entry form, and upon loading an order (tied to that quote line), the Sales Order Comment is updated with the Job comments from the quote.

Not shown, is that if I disable the BPM, then change the quote job comment, the order lines retain their prior values.

Today it worked. I don’t know why yesterday wasn’t working, I changed nothing.
Probably was another customization interfering.

Thanks for all your help!

I often forget to save the BPM when testing. :frowning:

The BPM isn’t truly updated after saving and closing the Designer window… You have to save the BPM itself too.