Use VTAP APIs for effortless data access, retrievals & updates!
VTAP APIs offer powerful functions that enable you to retrieve data, update records, change data, etc.
With VTAP APIs, developers can easily perform tasks like data retrieval and updates, ensuring smooth integration and efficient data management within the CRM environment.
For example, you can fetch user-specific records with comprehensive details about the currently logged-in user, granting access to vital information such as user preferences, roles, and permissions. You can also update contact details or other CRM data in real-time.
In this edition, we give the following two examples:
How to retrieve the details of a currently logged-in user using VTAP API?
How to retrieve Tax Management details (such as Taxes, Charges, and Tax Regions) for an Inventory module using the VTAP API?
Let us take a look.
Example 1: Display a button based on the roles of the users.
var Contacts_Component_ListViewExamples = VTAP.Component.Core.extend({
created() {
var userInfo = VTAP.User();
var userRole = userInfo.roleid.label;
// Define the roles allowed to view the button
var allowedRoles = ['CEO','Sales Manager'];
if (allowedRoles.includes(userRole)) {
VTAP.Component.Register('LIST_BASIC_BUTTON', {
label: 'Custom Page',
clickHandler: () => {
window.location.href = " ";
},
icon: 'fa-check',
variant: 'primary'
});
}
}
});
var Contacts_Component_ListViewExamples = VTAP.Component.Core.extend({
created() {
var userInfo = VTAP.User();
var userRole = userInfo.roleid.label;
// Define the roles allowed to view the button
var allowedRoles = ['CEO','Sales Manager'];
if (allowedRoles.includes(userRole)) {
VTAP.Component.Register('LIST_BASIC_BUTTON', {
label: 'Custom Page',
clickHandler: () => {
window.location.href = " ";
},
icon: 'fa-check',
variant: 'primary'
});
}
}
});
Note: You will get the role of the user from VTAP.user() (user info). Based on the user role you can restrict the button like show/hide.
Example 2 - How to retrieve Tax Management details (such as Taxes, Charges, and Tax Regions) for an Inventory module using VTAP API?
Use the Describe Core API to retrieve detailed information about a specific inventory module. For example, use the Describe Core API to fetch detailed information about the Quotes module.
VTAP.Api.Get("describe", {
"module": "Quotes",
}, (error, response) => {
if (error) {
console.error("Error:", error);
}
});
VTAP.Api.Get("describe", {
"module": "Quotes",
}, (error, response) => {
if (error) {
console.error("Error:", error);
}
});
Note:
In the API response, all information related to charges and taxes can be found under the chargesAndItsTaxes key.
In the API response, the information related to tax regions can be found under the tax_regions key.
Example 3 - How to update Inventory Line Item block fields Charges and Over All Discount?
3a. How to update charges using VTAP API?
Follow these steps to update charges:
Retrieve the record using the VTAP.API.GET method.
Access the chargesAndItsTaxes object in the response and identify each charge.
Modify the key value for each charge within the chargesAndItsTaxes object.
Send the updated object in the Vtap.API.put request, ensuring that you include it under the charges key.