I’m writing a BPM that modifies the sales order when it is created from the quote. When I run a trace the log does not show any sales order methods being called. Does anyone have any experience with the quote to order methods?
Have a look at this post, it shows how to find and set fields on a Sales Order from a quote
You can set any header fields with this code and with a little tinkering you can set detail fields too
There are two methods (from two BO’s) that create an order from a quote. If you’re in Quote Entry, then Quote.CreateOrder()
is used.
If your in Order Entry, then something like Sales.GetQuote()
(I’m sure that’s not right, I’m going from memory. Just look for a Sales method whose name implies making the order from a quote)
Thanks that’s a great example. I’m trying to make changes to the lines instead of the header. When i run this it modifies the first line of the order but not the following lines.
Ok, can you post what you have done, I’ll have a look at it
Some examples…
//Sets OrderDtl fields
var OrderDtls = Db.OrderDtl.Where(o => o.Company == Session.CompanyID && o.OrderNum == orderNum).ToList();
if(OrderDtl != null)
{
foreach( var OrderDtl in OrderDtls)
{
OrderDtl.field1Name = "value"; // or other reference
}
}
//Sets SO detail fields from quoteDtls
var orderDtls = Db.OrderDtl.Where(o => o.Company == Session.CompanyID && o.OrderNum == orderNum).ToList();
if(orderDtls != null)
{
foreach(var orderDtl in orderDtls)
{
var quoteDtl = Db.QuoteDtl.Where(qd => qd.Company == Session.CompanyID && qd.QuoteNum == orderDtl.QuoteNum && qd.QuoteLine == orderDtl.QuoteLine).FirstOrDefault(); // this will pull all fields from quote detail you may want to limit this
orderDtl.Fieldtoupdate = quoteDtl.fieldName;
}
}
//Sets SO detail fields from quoteDtls (limited fields)
var orderDtls = Db.OrderDtl.Where(o => o.Company == Session.CompanyID && o.OrderNum == orderNum).ToList();
if(orderDtls != null)
{
foreach( var orderDtl in orderDtls)
{
var quoteDtl = Db.QuoteDtl.Where(qd => qd.Company == Session.CompanyID && qd.QuoteNum == orderDtl.QuoteNum && qd.QuoteLine == orderDtl.QuoteLine).Select(x => new{x.field1Name, x.field2Name}).FirstOrDefault();
orderDtl.Field1toupdate = quoteDtl.field1Name;
orderDtl.Field2toupdate = quoteDtl.field2Name;
}
}
Also on Github
I believe I have it figured out thanks to your examples. Thank you !
i don’t know if you can help me.
I have progress code and i need to convert in SQL/C# and i start in programation and i never saw progress.
the progress abl code is
FOR EACH ttQuoteDtl :
FIND FIRST OrderDtl WHERE OrderDtl.Company = ttQuoteDtl.Company AND OrderDtl.OrderNum = OrderNum AND
OrderDtl.QuoteNum = ttQuoteDtl.QuoteNum AND OrderDtl.QuoteLine = ttQuoteDtl.QuoteLine EXCLUSIVE-LOCK NO-ERROR.
IF AVAILABLE OrderDtl THEN
DO:
ASSIGN OrderDtl.Reference = String(ttQuoteDtl.Number09, "9.999").
FIND FIRST OrderHed WHERE OrderHed.Company = OrderDtl.Company AND OrderHed.OrderNum = OrderDtl.OrderNum EXCLUSIVE-LOCK NO-ERROR.
IF OrderHed.OrderComment = "" THEN
DO:
FIND FIRST ttQuoteHed WHERE ttQuoteHed.Company = ttQuoteDtl.Company AND ttQuoteHed.QuoteNum = ttQuoteDtl.QuoteNum NO-LOCK NO-ERROR.
ASSIGN OrderHed.OrderComment = ttQuoteHed.QuoteComment.
Assign OrderHed.UserChar1 = ttQuoteHed.UserChar1.
END.
END.
END.