You are here: Offline capability > Function rule support in offline mode > How to use a function rule in offline mode

How to use a function rule in offline mode

If you create your own function rule that is available for Java and would like it to be also available in offline-enabled applications, you must create its JavaScript equivalent. You must specify the namespace where this JavaScript equivalent function rule is created. A JavaScript function rule you create can be called in one of the following ways:

Converter API

You can use the following offline converter API in your JavaScript function custom code. These functions allow you to parse the input parameters that are used for validation, and then convert them back to the required type, as the output.

The following functions use JavaScript value or object, or a Pega Platform string as its argument and return a JavaScript object.

pega.offline.converter.parseDate(date)
pega.offline.converter.parseDateTime(dateTime)
pega.offline.converter.parseDecimal(decimal)
pega.offline.converter.parseDouble(double)
pega.offline.converter.parseInteger(integer)
pega.offline.converter.parseTimeofDay(timeofDay)
pega.offline.converter.parseTrueFalse(boolean)

The following functions return a Pega Platform string type.

pega.offline.converter.toDateString(date)
pega.offline.converter.toDateTimeString(dateTime)
pega.offline.converter.toDecimalString(decimal)
pega.offline.converter.toDoubleString(double)
pega.offline.converter.toIntegerString(integer)
pega.offline.converter.toTimeofDayString(timeofDay)
pega.offline.converter.toTrueFalseString(boolean)