Solved

How to Identify unique line from Sales Quote to Sales Order?

  • 20 March 2023
  • 5 replies
  • 159 views

Userlevel 3
Badge

Hi Everyone,

When we are converting the Sale Quote to Sales Order, we are updating few custom fields and implemented with the below logic it is working fine, but when we have same line items and could not able to identify the unique line and values are not copying from Sales Quote to Sales Order.

can anyone help me with this?

I know that As I comparing only Inventory ID, then I’m seeing this issue but is there any field that we can identify uniquely?

 

   public class QuoteMaintExt : PXGraphExtension<QuoteMaint.CRCreateSalesOrderExt, QuoteMaint>
{
public static bool IsActive() => true;

[PXOverride]
public IEnumerable createSalesOrder(PXAdapter adapter, Func<PXAdapter, IEnumerable> baseMethod)
{
PXGraph.InstanceCreated.AddHandler(delegate (SOOrderEntry graph)
{
graph.RowUpdated.AddHandler<SOLine>(delegate (PXCache sender, PXRowUpdatedEventArgs e)
{
SOLine objSOLine = e.Row as SOLine;
if (objSOLine != null)
{
SOLineExt objLineExt = objSOLine.GetExtension<SOLineExt>();
foreach (CROpportunityProducts item in Base.Products.Select().FirstTableItems.ToList().Where(x => x.InventoryID == objSOLine.InventoryID))
{
CROpportunityProductsExt objItemExt = item.GetExtension<CROpportunityProductsExt>();
sender.SetValue<SOLineExt.usrTestField1>((object)objSOLine, objItemExt.UsrTestField1);
sender.SetValue<SOLineExt.usrTestField2>((object)objSOLine, objItemExt.UsrTestField2);

}
}
});

});
return baseMethod(adapter);
}
}

 

icon

Best answer by Naveen Boga 21 March 2023, 05:42

View original

5 replies

Userlevel 7
Badge +16

Hi @nsmith51 

I am not a developer nor do I do customizations but in Acumatica, each line on the Sales Order does have a Line Number. 

You can view it by clicking on the column configurator and adding the Line Nbr to the grid.

 

Userlevel 7
Badge +8

@nsmith51 

 

I made a slight change to your loop to cast to “CROpportunityProducts” as I guess the first table in the joins is “CRQuote” to avoid possible platform confusion and also added two extra restricting criteria as one of them was pointed out by @kandybeatty49 

 

Hope this resolves your issue.

                    foreach (CROpportunityProducts item in Base.Products.Select()
.FirstTableItems.RowCast<CROpportunityProducts>().ToList()
.Where(x => x.InventoryID == objSOLine.InventoryID && x.LineNbr == objSOLine.LineNbr && x.SortOrder == objSOLine.SortOrder))

 

Userlevel 7
Badge +17

@nsmith51  Line Nbr field is NOT matching at all with the CROpportunity and SOLine. 

 

As a workaround, you can consider using the Sort Order field instead. However, it's uncertain if relying on this field is a reliable solution.

 

Userlevel 7
Badge +8

@Naveen Boga is Correct. Your CROpportunityProducts.LineNbr MIGHT NOT agree to SOLine.LineNbr if after Quote were created you delete lines from the middle of Quote Lines or you delete lines from SOOrder and adde extra lines to it.

I am not aware if Acumatica keeps any link between CROpportunityProducts and SOLine that we can utilize this link to make the code foolproof. @Naveen Boga Are you aware of any mapping table?

If there is no mapping table then your last option is to add a custom field to SOLine to keep a reference to CROpportunityProducts.LineNbr when a record is inserting by looking into CROpportunityProducts.Current.

Userlevel 7
Badge +17

@aaghaei  I think Acumatica is not maintaining the reference between SOLine and CROpportunity tables. But I have tested with Sort Order field with multiple options it seems it is working.

As you mentioned above, again this is customization and make sure maintain reference properly otherwise we end up with the issues. Before going with such customization it would be better if can check with Acumatica team and confirm this.

@VidhyaHariharasu00 @Nayan Mansinha @Dmitrii Naumov  @Dhiren Chhapgar  

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved