Schedule some task in Acumatica

2019-09-10 07:52发布

I have following task: execute some event with some interval. In T200 manual I found that it can be done via Processing pages. For this I need to add graph with suffix process. But what puzzles me is how to make to appear buttons Process, Process All, Schedules? Another question which I have is how to execute some action by some schedule in Acumatica? What is recommended approach?

1条回答
Juvenile、少年°
2楼-- · 2019-09-10 08:28

The key thing that distinguishes processing graphs from other kinds of pages in Acumatica is that they have a data view of type PXProcessing<> or PXProcessingJoin<> - these, together with a processing routine defined in the graph, will make the system create the Process, Process All and Schedule buttons on the corresponding screen. Generally your graph will look like this:

public class YourProcessingGraph : PXGraph<YourProcessingGraph>
{
    //Data view that provides a list of items to process
    public PXProcessing<ARInvoice,
        Where<ARInvoice.released, Equal<boolFalse>>> DocumentsToProcess;

    public YourProcessingGraph()
    {
        DocumentsToProcess.SetProcessDelegate(DoActualProcessing);

        //You can also change button captions
        DocumentsToProcess.SetProcessCaption("Do");
        DocumentsToProcess.SetProcessAllCaption("Do For All");
    }

    public static void DoActualProcessing(List<ARInvoice> itemsToProcess)
    {
        // Do something cool here
    }
}

You can find a better example of how to properly define a processing graph in the T200 training that you mention as well as in the source code of Acumatica - e.g. ARDocumentRelease graph.

Acumatica doesn't rely on the names of the classes that you define (be it DACs or graphs) when determining what is what, so the Process suffix (as well as Entry and Maint) is just a matter of style/convention. (One important exception is the customization objects that come with Cst prefix/suffix, but these are a bit different story.)

As for executing some action periodically, for this you use the Automation Schedules (SM205020) - that's the screen opened when you click the Schedule button on any processing screen. There you can create a schedule that would launch processing on a particular processing screen. The schedules can be fine tuned to match your goals in terms of frequency of execution and even allow for some additional filtering.

查看更多
登录 后发表回答