JavaScript API for running any activity in offline mode
The API for running activities helps you handle use cases that are unsupported in offline mode, by calling a JavaScript method from the custom code that immediately initiates an activity on the server.
When the app is online, the server returns response data and a success method is called. When the connection is not available or the call otherwise fails, a failure method is called.You can use the activity running feature, for example, to populate options for a drop-down control based on a property from the workpage, if you do not want to package the master list in the client store.
The API makes it possible to get filtered data from a larger amount of data that does not need to be packaged and stored in the client store. The API method passes the workpage JSON to the server and runs the specified activity in that context, so that the server filters the data, based on the workpage properties.
The API supports the ClassName.ActivityName notation so that you do not have to post any pages to the server. You run the activity in the server context and return the result to the callback. For example, you can use this API for a search box control that works only in online mode.
The following JavaScript method is available for the ServerProxy
object:
Method | Description |
executeBreakoutCall( activityName, activityParams, callback
) | Posts the pyWorkPage page to the server and runs the
specified activity in that context, outside of offline mode of the offline-enabled
application. The returned data is passed to the success callback that is specified
when calling this method. The method has the following parameters:
|
Example
You can use the following JavaScript code to run the RunActivity activity, which is part of the WW-WebWiz-Work-NoNosco class, when an offline-enabled mobile app connects to a network, and pass the parameters as key and value pairs. To call an activity on the server in the specified class, you must add the class name as a prefix to the activity name in the activityName parameter.
var oSafeURL = new SafeURL();
oSafeURL.put("InsHandle", "actual_handle");
pega.u.d.ServerProxy.executeBreakoutCall(“WW-WebWiz-Work-NONOsco.RunActivity” , osafeURL, {
success: function( data ) {
// custom code
},
failure: function() {
// code to display information that the call failed
},
scope: window
});
Previous topic Enabling online-only features in offline mode Next topic JavaScript API for scheduling any activity in offline mode