Sage 300 How to Return Super View Values from the Process Service

3 minute read time.

Introduction

So, you are developing Web Screens for Sage 300 and you want to be able to check a field value or some field values that are returned from the super view. In the Sage 300 Desktop, which is based upon the Visual Basic 6.0 development environment, this is simple and straight-forward.

But, how is this done in the Web Screens where the process is handled by a Worker Role?

This article will explain how this is accomplished by looking at our Sage 300 Web Screen Payment Batch Unit of Work (UOW) service implementation as an example.

Process Flow

But, before we begin, let’s briefly review the Web and Worker Roles as they relate to a Process task.

The Sage 300 Web Architecture uses both web and worker roles to serve the functionality of the web screens. Worker roles are used for most long running processes, usually indicated by a progress-meter, and some reports.

The above diagram illustrates the flow once a process screen submits or starts the process.

Because the super view is handled and processed in the worker role, the business view (which is mapped to an MVC model) is not returned to the web role to access the required values.

Process UOW Service

The Process UOW Service is the class that invokes the Process Repository where the super view’s Process function is invoked and hydrates a model upon return from the function.

var model = repository.Process(seedEntity.Model);

But, this model is in the worker role and the model is not serialized back to the web role.

Process Result’s ResultObject

The ResultObject in the ProcessResult object will contain the value or values that you will want to return to the web role. But, you must place what you want in this object since we do not serialize the model into this object (hindsight says we should have!).

Prior to Sage 300 2019, the setting of the ResultObject was done by the developer by overriding the Process UOW’s OnExecute base class method. The following routine is from our 2018.2 implementation of the Payment Batch UOW class:

While overriding this base class method effectively was able to access and set the ResultObject, it also needlessly had to implement a lot of other code.

Sage 300 2019 eliminated the need to override the OnExecute base class method by providing an override method which provides the ability to set the ResultObject without re-implementing the base class method. The overridden OnExecute was deleted in the Payment Batch UOW class and replaced with an override to the GetResultObject method instead:

Back in the Web Role

At the completion of the process, control is returned to the screen’s JavaScript callback function onProcessComplete. If the ResultObject was set in the Process UOW Service’s override method GetResultObject, it is now available in this callback event:

Summary

This article explained how to return a super view value or values from a process service in the Sage 300 Web Screens.

As indicated in the XML Comments for the GetResultObject virtual method, since this is a single object and not an array or dictionary, if multiple values are required, use the pipe symbol as separator to concatenate multiple fields.

The GetResultObject is a virtual method that can be overridden in the Process UOW service class to return a value or values from the worker role to the web role.

The onProcessComplete JavaScript callback function is invoked at the completion of the process and the ProcessResult.ResultObject is available for the developer with any values that may have been set in the worker role. By default, the ResultObject is null.

So, not as simple as the desktop implementation, but still doable with a few extra steps!

As a standard disclaimer, any topic in this article is subject to review and doesn’t represent a commitment as to when it will be available.