VTAP API を使用すると、データへのアクセス、取得、更新が簡単になります。

VTAP API は、データの取得、レコードの更新、データの変更などを可能にする強力な機能を提供します。

VTAP API を使用すると、開発者はデータの取得や更新などのタスクを簡単に実行でき、CRM 環境内でのスムーズな統合と効率的なデータ管理が保証されます。

たとえば、現在ログインしているユーザーに関する包括的な詳細情報を含むユーザー固有のレコードを取得し、ユーザーの設定、役割、権限などの重要な情報へのアクセスを許可できます。また、連絡先の詳細やその他の CRM データをリアルタイムで更新することもできます。

この版では、次の 2 つの例を示します。

  • VTAP API を使用して現在ログインしているユーザーの詳細を取得するにはどうすればよいですか?
  • VTAP API を使用して在庫モジュールの税務管理の詳細 (税金、料金、税地域など) を取得するにはどうすればよいですか?

見てみましょう。

例 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 を使用して、見積モジュールに関する詳細情報を取得します。


  

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);

    } 

});

お願い:

  • API レスポンスでは、料金と税金に関連するすべての情報が、chargesAndItsTaxes キーの下にあります。
  • API レスポンスでは、税地域に関連する情報は tax_regions キーの下にあります。

例 3 - 在庫明細ブロック フィールドの料金と全体割引を更新するにはどうすればよいでしょうか?

3a. VTAP API を使用して料金を更新するにはどうすればよいですか?

料金を更新するには、次の手順に従ってください。

  • VTAP.API.GET メソッドを使用してレコードを取得します。
  • 応答内のchargesAndItsTaxesオブジェクトにアクセスし、各料金を識別します。
  • ChargesAndItsTaxes オブジェクト内の各料金のキー値を変更します。
  • 更新されたオブジェクトを Vtap.API.put リクエストで送信し、必ずそれを charge キーの下に含めるようにします。

料金の例:


  

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) => {});


  

VTAP.Api.Put('records', {

        module: 'Quotes',

        id: VTAP.Detail.Id(),

        hdnProductId1: 490,

        totalProductCount: 1,

        discount_amount_final: 500,

        discount_type_final: 'amount',

    }, (error, response) => {});

パーセンテージタイプの全体割引の例:


  

VTAP.Api.Put('records', {

        module: 'Quotes',

        id: VTAP.Detail.Id(),

        hdnProductId1: 490,

        totalProductCount: 1,

        discount_percentage_final: 10,

        discount_type_final: 'percentage',

    }, (error, response) => {});


  

VTAP.Api.Put('records', {

        module: 'Quotes',

        id: VTAP.Detail.Id(),

        hdnProductId1: 490,

        totalProductCount: 1,

        discount_percentage_final: 10,

        discount_type_final: 'percentage',

    }, (error, response) => {});

これらの例により、VTAP API の使用感が向上し、必要なデータを正確に取得できるようになると確信しています。今後も引き続きご注目ください。

ハッピーコーディング!

 
 

サインアップして最新のアップデートを受け取りましょう!