使用 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 檢索庫存模組的稅務管理詳細資訊(例如稅金、費用和稅區)?
使用描述核心 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。