The comments box on Quote Lines wasn’t big enough, so we created a Custom field:
QuoteDtl.ExtraComments_c
We want these to push to the sales order line detail (and print on the sales order acknowledgement form) so we created a matching field:
OrderDtl.ExtraComments_c
When the quote is pushed to a sales order (using Opportunity Quote Entry > create Sales Order), we want to comments to push from the quote line through to the sales order line.
I’ve been able to create a BPM on Erp.BO.Quote.CreateOrderFromQuote
to display a message when a quote containing anything in the QuoteDtl.ExtraComments_c field is converted to a quote so I know I have the right BO, in pre-processing
I have been able to push the Quote number, line and comments to the Ice.UD02 table using this BPM, also using pre-processing.
How can I get the comments to push to the sales order line field?
Do I need to enable a post processing method and push the Ice.UD02 fields to the orderdtl.ExtraComments_c field?
I have seen other posts on similar topics but none have been clear enough or similar enough for me to follow.
Thank you
Current method:
Erp.BO.Quote.CreateOrderFromQuote
Pre Processing
Condition
The
dsQuoteDtlRow.UDField<System.String>(“ExtraComments_c”) == null
expression is invalid
True = Fill Table by Query
ds.QuoteDtl.Company = Erp.QuoteDtl.Company
ds.QuoteDtl.QuoteNum = Erp.QuoteDtl.QuoteNum
ds.QuoteDtl.QuoteNum = Erp.QuoteDtl.QuoteNum
Display Fields
all of the above plus
ds.QuoteDtl.ExtraComments_c
Erp.QuoteDtl.ExtraComments_c
Fill Table by Query:
Use the KM01 Query to insert data into the UD02KMLogs.UD02table with configured mapping
Invoke IceUD02.UpdateExt BO Method with configured parameters (see screenshot)
I added notes for what the code was doing
and had to comment out the bits which caused errors
such as the Transaction Scope
(error on Epicor:
CreateOrderFromQuote.Post.KmPost1.AsyncHost.cs(91,1): warning CA1416: This call site is reachable on all platforms. ‘TransactionScope.Complete()’ is only supported on: ‘Windows’.)
My custom code:
/*KM Code Summary
In summary, this code retrieves the extra comments from a quote associated with a specific sales order and updates the corresponding sales order’s extra comments field with that value. The entire operation is wrapped in a transaction to ensure data integrity.*/
/*
#1 Retrieve the Quote Number
This line queries the OrderDtl table to find the QuoteNum associated with a specific sales order (orderNum) for the current company (Session.CompanyID). It retrieves the first matching QuoteNum or null if no match is found.
*/
/* #1 */
var quoteNum = Db.OrderDtl.Where(o => o.Company == Session.CompanyID && o.OrderNum == orderNum).Select(x => x.QuoteNum).FirstOrDefault();
/*
#2 Check if Quote Number Exists:
This checks whether a valid quote number was retrieved. If it's null, the subsequent code block will not execute.
*/
/* #2 */
if (quoteNum != null) {
/*
#3 Retrieve the Extra Comments from the Quote:
If a valid quoteNum is found, this line queries the QuoteDtl table to retrieve the ExtraComments_c field associated with that quote number for the current company. It selects the first matching record or null if no match is found.
*/
/* #3 */
var quote = Db.QuoteDtl.Where(q => q.Company == Session.CompanyID && q.QuoteNum == quoteNum).Select(x => new {x.ExtraComments_c}).FirstOrDefault();
/*
#4 Check if Quote Details Exist:
This checks if the quote details were successfully retrieved.
*/
/* #4 */
if (quote != null) {
/*
#5 Update the Sales Order:
If the quote exists, this block starts a transaction scope to ensure that the operations are atomic.
It retrieves the sales order header (OrderHed) associated with the given orderNum, applying an update lock to prevent conflicts.
It then copies the value from quote.ExtraComments_c to order.ExtraComments_c, effectively transferring the extra comments from the quote to the sales order.
The Db.Validate() line checks for any validation issues before committing the changes.
Finally, txScope.Complete() commits the transaction.
Validation was fine but when I enabled the BPM Epicor threw an error message "CreateOrderFromQuote.Post.KmPost1.AsyncHost.cs(91,1): warning CA1416: This call site is reachable on all platforms. 'TransactionScope.Complete()' is only supported on: 'Windows'." so I commented out some parts and it still works
*/
/* #5 */
/*
using (var txScope = IceContext.CreateDefaultTransactionScope())
*/
{
var orderDtl = Db.OrderDtl.With(LockHint.UpdLock).Where(o => o.Company == Session.CompanyID && o.OrderNum == orderNum).FirstOrDefault();
if(orderDtl != null)
{
orderDtl.ExtraComments_c = quote.ExtraComments_c;
}
Db.Validate();
/* txScope.Complete();*/
}
}
}
You should use a dd as was done in the post you referenced, or place similar code on Order Wizard BO or you may end up with records that have not hit that BPM. Unless this has been adjusted in Kinetic to always hit that BO from all Order from Quote paths.