Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 1.56 KB

PX1013.md

File metadata and controls

60 lines (46 loc) · 1.56 KB

PX1013

This document describes the PX1013 diagnostic.

Summary

Code Short Description Type Code Fix
PX1013 The action handler that initiates a background operation or is executed by a background operation must return IEnumerable. Error Available

Diagnostic Description

To work properly with background operations, the action handler must return IEnumerable. If you use the void action handler, the processing of the long-running operation and its result will not be displayed in the UI.

The code fix changes the return type to IEnumerable.

Example of Incorrect Code

public class SMUserProcess : PXGraph
{
	public PXSelect<Users> Users;

	public PXAction<Users> SyncMyUsers;

	[PXButton]
	[PXUIField]
	public virtual void syncMyUsers() // The PX1013 error is displayed for this line.
	{
		SyncUsers();
	}
		
	private void SyncUsers()
	{
		PXLongOperation.StartOperation(this, () => Console.WriteLine("Synced"));
	}
}

Example of Code Fix

public class SMUserProcess : PXGraph
{
	public PXSelect<Users> Users;

	public PXAction<Users> SyncMyUsers;

	[PXButton]
	[PXUIField]
	public virtual IEnumerable syncMyUsers(PXAdapter adapter)
	{
		SyncUsers();
			return adapter.Get();
		}
		
	private void SyncUsers()
	{
		PXLongOperation.StartOperation(this, () => Console.WriteLine("Synced"));
	}
}