Skip to content

Latest commit

 

History

History
70 lines (57 loc) · 4.46 KB

File metadata and controls

70 lines (57 loc) · 4.46 KB

PX1080

This document describes the PX1080 diagnostic.

Summary

Code Short Description Type Code Fix
PX1080 Data view delegates should not start long-running operations. Error Unavailable

Diagnostic Description

Data view delegates should not start long-running operations. A data view delegate is designed to prepare a data set to display it in the UI. Typically, if the results of a long-running operation are not awaited synchronously (the operation is asynchronous), the results of the data view delegate are returned before the end of the long-running operation. However, this scenario is not supported by the Acumatica Framework: If a data view delegate starts an asynchronous long-running operation, it may lead to unexpected behavior.

If the results of the long-running operation are awaited synchronously, starting a long-running operation from a data view delegate is still strongly discouraged due to the following reasons:

  • A synchronous wait for the data from the external service negatively impacts the user experience.
  • The paging mechanisms of the Acumatica Framework may work incorrectly.
  • The approach does not scale well. There are no observable problems when there are only 10-50 records retrieved from the external service. However, the solution rapidly deteriorates when the amount of external data grows to 50 000 - 100 000 records. Such cases were observed by Acumatica support.
  • Any disruption of the external service (for example, some trivial issues after OS upgrade on the server where the service is hosted) will prevent the affected Acumatica ERP screen from opening. Neither Acumatica, nor the customization authors can guarantee the stability of the external service. Such situations take a lot of time and effort for investigation keeping the customer annoyed and frustrated with Acumatica ERP even though the real problem was caused by another service.

Long-running operations are started by the following APIs:

  • PXLongOperation.StartOperation methods
  • ILongOperationManager.StartOperation, ILongOperationManager.StartAsyncOperation, and ILongOperationManager.Await methods
  • IGraphLongOperationManager.StartOperation and IGraphLongOperationManager.StartAsyncOperation methods

To prevent the error from occurring, you should remove the code that starts a long-running operation from the data view delegate and rework the related business logic.

The alternative approach recommended by the Acumatica ISV Support team:

  • If there is a small amount of data to retrieve from the external service, then you can use a virtual DAC which is populated when a user clicks an action.
  • If there is a large amount of data to retrieve from the external service, then you should store the data locally in the database. You should obtain the data updates from the external service and synchronize them with the locally stored data when a user clicks a specific action. The data synchronization can be also performed via the push notifications mechanism.

Example of Incorrect Code

public class ShipmentProcess : PXGraph<ShipmentProcess>
{
	[PXFilterable]
	public PXFilteredProcessingJoin<SOShipment, ShipFilter,
	LeftJoin<Customer,
		On<SOShipment.customerID, Equal<Customer.bAccountID>>>,
	Where<CustomerExtension.sCust, Equal<True>,
		And<CustomerExtension.sReq, Equal<True>>>>
	ShipmentList;

	protected virtual IEnumerable shipmentList()
	{
		var sel = new PXSelectJoin<SOShipment,
			InnerJoin<BAccount,
				On<SOShipment.customerID,
					Equal<BAccount.bAccountID>>>>(this);
	
		PXLongOperation.StartOperation(this, delegate () //The PX1080 error is displayed for this line.
		{
			//update records
		});
		return sel.Select();
	}
}

Related Articles