使用 VTAP API 轻松访问、检索和更新数据!
VTAP API 提供强大的功能,使您能够检索数据、更新记录、更改数据等。
借助 VTAP API,开发人员可以轻松执行数据检索和更新等任务,确保在 CRM 环境内顺利集成并高效管理数据。
例如,您可以获取特定于用户的记录,其中包含有关当前登录用户的全面详细信息,并授予对用户偏好、角色和权限等重要信息的访问权限。您还可以实时更新联系人详细信息或其他 CRM 数据。
在本版中,我们给出以下两个示例:
让我们来看看。
示例 1:根据用户的角色显示按钮。
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'
});
}
注意::您将从 VTAP.user()(用户信息)获取用户的角色。根据用户角色,您可以限制按钮的显示/隐藏。
示例 2 - 如何使用 VTAP API 检索库存模块的税务管理详细信息(例如税金、费用和税区)?
使用 Describe Core API 检索有关特定库存模块的详细信息。例如,使用 Describe Core API 获取有关 Quotes 模块的详细信息。
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);
注意::
示例 3 - 如何更新库存明细项目块字段费用和总折扣?
3a. 如何使用 VTAP API 更新费用?
请按照以下步骤更新费用:
收费示例:
VTAP.Api.Put('records', { module: 'Quotes', id: VTAP.Detail.Id(), hdnProductId1:<product_id>, totalProductCount: 1, charges: {} }, (error, response) => {});
VTAP.Api.Put('records', {
module: 'Quotes',
id: VTAP.Detail.Id(),
hdnProductId1:<product_id>,
totalProductCount: 1,
charges: {}
}, (error, response) => {});
3b. 如何使用 VTAP API 更新整体折扣?
整体折扣可以是直接金额或百分比,因此我们需要将折扣类型与折扣金额一起发送。
金额类型的总体折扣示例:
VTAP.Api.Put('records', { module: 'Quotes', id: VTAP.Detail.Id(), hdnProductId1: 490, totalProductCount: 1, discount_amount_final: 500, discount_type_final: 'amount', }, (error, response) => {});
hdnProductId1: 490,
discount_amount_final: 500,
discount_type_final: 'amount',
百分比类型的总体折扣示例:
VTAP.Api.Put('records', { module: 'Quotes', id: VTAP.Detail.Id(), hdnProductId1: 490, totalProductCount: 1, discount_percentage_final: 10, discount_type_final: 'percentage', }, (error, response) => {});
discount_percentage_final: 10,
discount_type_final: 'percentage',
我们相信这些示例将改善您使用 VTAP API 的体验,确保您准确检索所需的数据。敬请期待更多内容。
编码愉快!
注册以接收最新更新!
我已阅读 私隐政策 Vtiger。