You are here: Offline capability > Data transform support in offline mode > Offline data transform API

Offline data transform API

The offline data transform API consists of a JavaScript method that allow you to run a data transform in offline-enabled applications by using a Run script action or a custom JavaScript function. To package such a data transform rule for offline use, you must add the data transform definition to the pyDataTransformWhitelistForOffline rule.

The following JavaScript method is available for the pega.offline object:

Method

Description

runDataTransform( datatransformName,
className, pageName, callback )

Runs a data transform with the specified name. The data transform rule can be run in the specified page context.

The method has the following parameters:

    datatransformName Required. Specifies the name of the data transform to run.
    className Required. Specifies the name of the class that the data transform belongs to.
    pageName Optional. Specifies the name of page (page context) in which the data transform needs to be run. If this parameter is not specified or is set to a null value, the data transform will run in the primary page context.
    callback Optional. Specifies a JavaScript object that contains success and fail methods. The success method is called when the data transform has been run successfully. The fail method is called when an error occurs after the data transform is run.

Example

The following sample JavaScript code allows you to run a data transform called SampleDT, which belongs to the MY-SAMPLE-WORK-DATATRANSFORMS class, in the primary page context, from a custom JavaScript function:


var offlineDTCallback = {
   success: function() {
      console.log("Data transform ran successfully");
   }
   fail: function() {
      console.log("Failed to run Data transform");
   }
};
pega.offline.runDataTranform( "SampleDT",
                              "MY-SAMPLE-WORK-DATATRANSFORMS",
                               null,
                               offlineDTCallback);