Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

JavaScript API for running any activity in offline mode

Updated on November 9, 2021

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:

MethodDescription
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:

activityName
Required. Specifies the name of the activity to run on the server.
activityParams
Optional. Specifies a SafeURL object that holds key and value pairs for the activity parameters.
callback
Optional. Specifies a JavaScript object that contains success and failure methods, and the scope property. The success method is called when the call is successful. The failure method is called when an error occurs during the call. The scope property specifies the scope in which the callbacks must run.
Note: The JavaScript docs that are available in the webwb/safeURL.js text file contain a description of all SafeURL functions that are used to assemble, encode and return URLs and query strings.

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

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us