Getting Started

Pepperi JS Client Side API enables you to extend our Native and Web Apps. The run-time of the API is either from our Rule-Engine-based User Define Fields or from our Workflow's Custom Web Forms

Namespace: pepperi.api

pepperi.api VS pepperi.app

  • The pepperi.api namespace functions do not trigger any auto-calculation of the app's business logic (rule engine) for that purpose the namespace "app" should be used instead.

  • Both "api" and "app" can be used inside a web custom form (visible or hidden) as a step in a workflow

  • Only "api" functions can be called from the rule engine = calculated user defined fields

the only functions supported in the "app" namespace are:

  1. pepperi.app.accounts.update

  2. pepperi.app.activities.update

  3. pepperi.app.transactions.update

  4. pepperi.app.transactionLines.update

  5. pepperi.app.transactionScopeItems.update

  6. pepperi.app.transactions.addLines

  7. pepperi.app.transactions.removeLines

Async: Custom Web Forms VS calculated UDF (rule engine)

In web custom forms only - the Client API work Async - for all functions , so that 2 parameters are always added: responseCallback and requestID - requestID is optional - recommended to identify the request upon getting the Async response.

For example:

pepperi.api.activities.get({ key: {UUID: "aefb523e-74ac-4041-8bb1-a76a3b5e78d8"} ,
 fields: [ "ExternalID" , "MyTSA"],
 responseCallback: "<your_callback_function>" ,requestID: "<your_request_id>"} )

Date and Time: UTC only

Date format in the API : Dates are retrieved and should be updated in UTC only, in the ISO 8601 format: 2018-12-18T12:29:02Z or 2018-12-18Z

Rule Engine Date format: dates are retrieved in the Rule Engine GetValueByAPIName function in the unix timestamp format - seconds since Jan 01 1970. (UTC) see here : https://www.unixtimestamp.com/ and therefor will need to be converted in order to change the field value and update it back through the API . code sample for the Rule Engine calculated fields :

var date = new Date(TSACaptureDateTime*1000); //first convert to seconds 
var ret_object=pepperi.api.accounts.update({
      objects: [{
                 UUID: GetValueByApiName("Account.UUID") , 
                 TSALastActiveDate:date.toISOString()  // then update to UTC ISO format
                }]
    });    
}

Filters : Dates can be provided to the filter object in a non-UTC format, and the function will convert it internally to UTC.

Logs : send logs to our servers to track issues

On iOS and Android - the logs will be sent in case the app crashes - and on the web app logs are sent to our servers constantly in real-time

pepperi.log({ message: "<your message>", verbosity:"Low" });

Verbosity' is optional. (Low, Medium , High ) default is 'Low'

Error Handling

On Error - all functions returns the same error object:

{ success:false, value:"", error:{ code:54, message :"<relevant error messagge>" } }

Context : Run-time scope of data retrieval and data update

this function is more important for the web custom forms - since the code in the custom form is always a part of a workflow and therefore its important to be able to get it's run-time scope

pepperi.app.getContext({responseCallback: "mycallback"});

This function also works in calculated fields.

var ret=pepperi.app.getContext({});

Returns an object to the call back function:

{
  "CPIDateTime": "2018-12-23T12:34:56Z",
  "appVersion": "",
  "appType": "web",
  "OSType": "",
  "OSVersion": "",
  "company": {
    "id": 30011895,
    "name": "Regine_DO_NOT_CHANGE_ClientAPI"
  },
  "user": {
    "id": 4492855,
    "uuid": "d8ce933a-a0dd-4a9f-9b88-c83581180dc5",
    "externalId": ""
  },
  "account": {
    "id": 18163276,
    "name": "Cat n Dog New",
    "uuid": "67274419-7f66-46f6-847a-72aa19d3db8a"
  },
  "transaction": {
    "id": -50,
    "externalId": "",
    "uuid": "131023c8-bbfd-4a15-ba4b-030fe7bdb44c"
  }
}

Filter object for the "search" functions

A "search" function is used all over the Client API to search for multiple objects.

Below is the most simple example for filter:

{ ApiName: "UnitPrice",
  Operation : ">=",   
   Values : ["7"]}

A filter can contain unlimited number of condition nodes, for example:

{ Operation : "AND",
          LeftNode: {ApiName: "UnitPrice", Operation : ">",
          Values : ["7"]},
          RightNode:{ApiName: "Transaction.ActionDateTime",
          Operation: "InTheLast", Values: ["4","Weeks"]}
}

Operators supported grouped by Data Type :

{
  "String": [
    "Contains",
    "StartWith",
    "EndWith",
    "IsEqual",
    "IsNotEqual",
    "IsEmpty",
    "IsNotEmpty"
  ],
  "Integer": [
    ">",
    "<",
    "=",
    ">=",
    "<=",
    "!=",
    "Between",
    "IsEmpty",
    "IsNotEmpty"
  ],
  "Real": [
    ">",
    "<",
    "=",
    ">=",
    "<=",
    "!=",
    "Between",
    "IsEmpty",
    "IsNotEmpty"
  ],
  "Boolean": [
    "IsEqual"
  ],
  "DateTime": [
    "Today",
    "ThisWeek",
    "ThisMonth",
    "Before",
    "After",
    "Between",
    "On",
    "InTheLast",
    "NotInTheLast",
    "DueIn",
    "NotDueIn",
    "IsEmpty",
    "IsNotEmpty"
  ],
  "File": [
    "IsEmpty",
    "IsNotEmpty"
  ],
  "MultiDropDown": [
    "IsEqual",
    "IsNotEqual",
    "IsEmpty",
    "IsNotEmpty"
  ],
  "PropertyMultiDropDown": [
    "IsEqual",
    "IsNotEqual",
    "IsEmpty",
    "IsNotEmpty"
  ],
  "UsersSpecialMultiDropDown": [
    "IsLoggedInUser",
    "IsEqual",
    "IsNotEqual",
    "IsEmpty",
    "IsNotEmpty"
  ]
}

Last updated