VTAP APIs: Empowering Developers to Simplify, Retrieve, and Innovate Seamlessly

VTAP APIs provide powerful functions that enable developers to efficiently retrieve, update, and manage data, as well as perform a variety of operations seamlessly.

In this edition, we give you the following examples:

  • Refresh a record using
  • Reload List View
  • Retrieve the user role details of the currently logged-in user
  • Retrieve the role details of specific users

Refresh a record using VTAP API for automatic data reload

The changes will not automatically appear on the front end when record details are updated using the POST or PUT methods. This is because these methods update the data on the server side, but the front end does not automatically fetch the latest data unless explicitly instructed to do so. To ensure the updated details are reflected on the front end, the page needs to be reloaded.

We can dynamically refresh the record using the VTAP API without the need for manual page reloads.

API: VTAP.Detail.RefreshRecord(); 

Example:


  

VTAP.Api.Put('records', {

module : ‘module_name’, 

id : ‘record_id’, 

field_name : ‘field_value’,

}, (error, response) => {                    

 If (response) {                        

VTAP.Detail.RefreshRecord();                         VTAP.Utility.ShowSuccessNotification("Record Updated Successfully.");                    

}

 });


  

VTAP.Api.Put('records', {

module : ‘module_name’, 

id : ‘record_id’, 

field_name : ‘field_value’,

}, (error, response) => {                    

 If (response) {                        

VTAP.Detail.RefreshRecord();                         VTAP.Utility.ShowSuccessNotification("Record Updated Successfully.");                    

}

 });

Document Reference Link: https://vtap.vtiger.com/platform/resources/vtap-js.html#vtap-detail-refreshrecord

Reload List View using the VTAP API

When a new record is created via the VTAP API from a list view interface, the list view does not automatically refresh to show the newly added record. Instead, the user has to manually reload the page to see the latest data.

The VTAP API refreshes List View dynamically without requiring a manual page reload.

API: VTAP.List.Reload();

Example:


  

VTAP.Api.Post('records', {

module : 'Contacts', 

firstname : 'John',

lastname : 'Wick', 

'email' : '[email protected]'

}, (error, response) => {

     If (response) {                        

VTAP.Utility.ShowSuccessNotification("Record Created Successfully.");  

VTAP.List.Reload();                  

}

});


  

VTAP.Api.Post('records', {

module : 'Contacts', 

firstname : 'John',

lastname : 'Wick', 

'email' : '[email protected]'

}, (error, response) => {

     If (response) {                        

VTAP.Utility.ShowSuccessNotification("Record Created Successfully.");  

VTAP.List.Reload();                  

}

});

Document Reference Link: https://vtap.vtiger.com/platform/resources/vtap-js.html#reload

Retrieve the user role details of the currently logged-in user using the VTAP API

A VTAP API is available that retrieves the details of the currently logged-in user. This API retrieves user details such as personal details, preferences, or system-related data.

Among the information returned by this API, there is a specific focus on the user's role details. 

By using this API, developers can seamlessly integrate user-specific functionalities and ensure proper authorization and personalized experiences based on the user's role.

API URL: “me”

Example:


  

VTAP.Api.Get('me', {

'module': 'Users'

}, (error, response) => {

If (response) {

const roleInfo = response.roleid;

         console.log(roleInfo.id); // Logs the role ID

         console.log(roleInfo.label); // Logs the role name

}

});


  

VTAP.Api.Get('me', {

'module': 'Users'

}, (error, response) => {

If (response) {

const roleInfo = response.roleid;

         console.log(roleInfo.id); // Logs the role ID

         console.log(roleInfo.label); // Logs the role name

}

});

Retrieve the role details of specific users using the VTAP API

You can retrieve role information for a specific user using the VTAP API by providing the user ID as a parameter.

Example:


  

VTAP.Api.Get('records', {

'module': 'Users',

‘Id’: ‘user_id’

}, (error, response) => {

If (response) {

const roleInfo = response.roleid;

         console.log(roleInfo.id); // Logs the role ID

         console.log(roleInfo.label); // Logs the role name

}

});


  

VTAP.Api.Get('records', {

'module': 'Users',

‘Id’: ‘user_id’

}, (error, response) => {

If (response) {

const roleInfo = response.roleid;

         console.log(roleInfo.id); // Logs the role ID

         console.log(roleInfo.label); // Logs the role name

}

});

 
 

Sign up to receive the latest updates!