1

Suggested by Arnold van Wageningen New 

We are creating a lot of Drop shipment sales order lines. PurchCreateFromSalesOrder::createPurchaseOrders generates the Direct delivery or Drop shipment Purchase order line. This is already somewhat slow. We however see that after Purchase order and Purchase order lines are created, PurchCreateFromSalesOrder::createPurchaseOrders calls PurchCreateFromSalesOrder::updateRelatedSalesLineRecords.



 This sets SalesDeliverNow to 0 for all Drop shipment.

   private void updateRelatedSalesLineRecords()

   {

       SalesLine relatedSalesLine;

       while select SalesLineRefRecId from tmpPurchLinePrice

               where tmpPurchLinePrice.Included

       {

           relatedSalesLine = SalesLine::findRecId(tmpPurchLinePrice.SalesLineRefRecId, true);

           if (relatedSalesLine.DeliveryType == TradeLineDlvType::DropShip)

           {

               relatedSalesLine.SalesDeliverNow = 0;

               relatedSalesLine.update();

           }

       }

   }

 

But in most scenarios, SalesDeliverNow is already 0, so there is no need to runs SalesLine.Update.

 

Due to additional custom extensions and ISV solutions, the additional sales line update may add more than 1 second for each drop shipment line insert:


ASK:

There is no need to set this field to 0 again. Because it is so time consuming, I would like to ask you to consider changing the code in PurchCreateFromSalesOrder::updateRelatedSalesLineRecords to:

 

   private void updateRelatedSalesLineRecords()

   {

       SalesLine relatedSalesLine;

       while select SalesLineRefRecId from tmpPurchLinePrice

               where tmpPurchLinePrice.Included

       {

           relatedSalesLine = SalesLine::findRecId(tmpPurchLinePrice.SalesLineRefRecId, true);

           if (relatedSalesLine.DeliveryType == TradeLineDlvType::DropShip

                

&& relatedSalesLine.SalesDeliverNow != 0)

           {

               relatedSalesLine.SalesDeliverNow = 0;

               relatedSalesLine.update();

           }

       }

   }

 


Reproduction steps

Demo company account USMF

1.     Open Released products and select item M0001

2.     In Fast tab Delivery, change Direct delivery to Yes:



3.     Save changes

4.     Open All sales orders form

5.     Create a new Sales order form customer US-004

6.     Add a line for item M0001

7.     Save the line

 


Actual result:

Sales order line is saved and automatically a Purchase order is created:


As part of the Purchase order creation, class method PurchCreateFromSalesOrder::createPurchaseOrders runs PurchCreateFromSalesOrder::updateRelatedSalesLineRecords:


This method changes SalesDeliverNow value for all new order lines with DeliveryType DropShip to 0:


In this scenario, this is not needed as SalesDeliveryNow is already set to 0.

 

Although impact on standard environment is small with around 100ms spent on the actual update:

 

On environments with some extensions on sales line updates, the impact might be much bigger. In our case, it adds around 1 second.

 


Expected result:

When inserting a new Sales order line with delivery type Drop shipment, SalesDeliverNow value is already 0 in most situations. Changing SalesDeliverNow might be required in some scenarios, but if it is already 0, there is no reason to update the sales order line.

 

Since we cannot extend PurchCreateFromSalesOrder code, we are requesting to consider changing PurchCreateFromSalesOrder::updateRelatedSalesLineRecords to only update the sales order line if SalesDeliverNow field is actually set to something else than 0:

   private void updateRelatedSalesLineRecords()

   {

       SalesLine relatedSalesLine;

       while select SalesLineRefRecId from tmpPurchLinePrice

               where tmpPurchLinePrice.Included

       {

           relatedSalesLine = SalesLine::findRecId(tmpPurchLinePrice.SalesLineRefRecId, true);

           if (relatedSalesLine.DeliveryType == TradeLineDlvType::DropShip

                

&& relatedSalesLine.SalesDeliverNow != 0

)

           {

               relatedSalesLine.SalesDeliverNow = 0;

               relatedSalesLine.update();

           }

       }

   }

 

Risk is minimal and it would reduce number of database calls considerably.

 


 



Business impact:

Although impact of this unnecessary SalesLine.Update on demo environment is minimal with around 100ms of execution time


on environments with ISV solutions and customizations, sales line updates are regularly taking much more time. In our case, this extra update takes around 1000ms:


In some of the companies sales workers are creating almost exclusively sales order lines with delivery type Drop shipment. Due to this, sales workers are spending considerable time waiting for this unnecessary sales line update.