VCAP

Vtiger Custom Application runtime (a.k.a VCAP) is a helper runtime script designed for applications built using VTAP's App Creator. It simplifies the process of interacting with CRM data and user APIs, making it easier for developers to retrieve or post records, trigger events, and manage configurations.

VCAP.userapi

.records.get

VCAP.userapi.records.get(params, cb) performs a GET request to retrieve records from a specified module in the Vtiger CRM. It uses the provided filter ID and search criteria to fetch the records and returns them through the callback function.

paramsobjectparameters required for the API call, it is to be given in key-value format
cb(callback)function(error,success)handler function gets response from server

Example: To retreive record information

VCAP.userapi.records.get({module: module, filterid: filterid,
    q: JSON.stringify(   searchWithOrClause(fields, term) )}, (e, response) => {
        //response has records data
});

.records.post

VCAP.userapi.records.post(params, cb) performs a POST request to create a new record in a specified module within Vtiger CRM. It sends the record data as parameters and returns the result through the callback handler.

paramsobjectparameters required for the API call, it is to be given in key-value format
cb(callback)function(error,success)handler function gets response from server

Example: To add an Event Record

VCAP.userapi.records.post({
    module      : "Events",
    subject     : "Testing with userapi ",
    eventstatus : " ",
    activitytype: " ",
    date_start  : showdate,
    time_start  : "09:00", 
    due_date    : showdate,
    time_end    : "10:30",
    contact_id: contactid
}, (e, response) => {
    //response will contain record data
});

VCAP.customapi

.get

VCAP.customapi.get(CustomApiName, parameters, cb) performs a GET request to a custom API endpoint defined in the Vtiger CRM. It sends parameters to the API and handles the response via a callback function.

CustomApiNameStringName of the Custom API you want to send request to.
You can checkout more about custom apis here
parametersobjectparameters required for the API call, it is to be given in key-value format
cb(callback)function(error,success)handler function gets response from server

Example:

VCAP.customapi.get("SearchTMDB", {moviename: "xxx"
    }, (e, response) => {
        //response contains the data received from the custom api
});

.post

VCAP.customapi.post performs a POST request to a custom API endpoint defined in the Vtiger CRM. It sends data to the API and handles the response via a callback function.

CustomApiNameStringName of the Custom API you want to send request to.
You can checkout more about custom apis here
parametersobjectparameters required for the API call, it is to be given in key-value format
cb(callback)function(error,success)handler function gets response from server

Example:

VTAP.CustomApi.Post("sendRequest",{identifier:13, managerId:652,managerName: "dghfc"}, (e,res) => {
        //response containds the record data
});

VCAP.Event

.trigger

VCAP.event.trigger('eventName', args) can be used to trigger custom events using this API, generally used when you have custom buttons, links and widgets.

eventNamestringname of the Event
args

Example :

$('#alertButton').on('click', function() {
		VCAP.event.trigger('alertEvent');  // Triggers the custom 'alertEvent'
});

.on

VCAP.event.on('eventName', func()) can be used, to listen for specific events that occur within the VCAP environment and perform necessary actions accordingly.

eventNamestringname of the Event
func()functionperforms necessary action once the event is triggered

Example :

VCAP.event.on('alertEvent', function() {
		alert("Showing alert on button click.");
});