Node JS SDKのサンプルコード - 設定操作

メタデータ
すべてのタブの取得
              
              
//GET ALL MODULES DATA

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};

crmclient.API.SETTINGS.getModules(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // Modules data value available as JSON Array of the 'modules' key of the JSON response
    // Each JSON object of the array corresponds to a module
    // By iterating the JSON objects of the array, individual module details can be obtained

    response = JSON.parse(response.body);
    response = response.modules;

    // Iterating the JSON array
    for(module in response) {
        var module_data = response[module];

        // For obtaining all the fields of the organization details, use the value of 'module_data' as such
        console.log(module_data);

        // For obtaining a particular field, use module_data.<api-name of field>
        // Sample API names: id, api_name
        console.log(module_data.api_name);
    }

});
 
特定のタブの取得
              
              
//GET A PARTICULAR MODULE DATA

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};
input.module = 'Leads'

crmclient.API.SETTINGS.getModules(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // The module details are obtained from the first JSON object of the JSON Array corresponding
    // to the 'modules' key of the response

    response = JSON.parse(response.body);
    response = response.modules[0];

    // For obtaining all the fields of the organization details, use the value of 'response' as such
    console.log(response);

    // For obtaining a particular field, use response.<api-name of field>
    // Sample API names: id, api_name
    console.log(response.api_name);

});
 
すべての役職の取得
              
              
//GET ALL ROLES DATA

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};

crmclient.API.SETTINGS.getRoles(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // Roles data value available as JSON Array of the 'roles' key of the JSON response
    // Each JSON object of the array corresponds to a role

    response = JSON.parse(response.body);
    response = response.roles;

    // For obtaining the entire response
    console.log(response);  


    // Iterating the JSON array to get individual role details
    for(role in response) {

        // Use response[role].<api-name of field> to obtain a specific field value
        // Sample API names: display_label, name
        // List of all available keys of the response can be seen in the JSON object corresponding to
        // a record. The entire object containig all keys can be obtained using 'response[role]'

        // Obtaining specific field value of a role
        console.log(response[role].name); 

        // Obtaining entire role details
        console.log(response[role]);  
    }
});
 
特定の役職の取得
              
              
//GET A SPECIFIC ROLE DATA

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};
input.id = '3519112000000026005';   // id: role-id
                                    // The role-id of the specific role

crmclient.API.SETTINGS.getRoles(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // The role data value is available as the first JSON object of the JSON Array
    // of the 'roles' key of the JSON response

    response = JSON.parse(response.body);
    response = response.roles[0];

    // For obtaining the entire role details
    console.log(response);  

    // Use response.<api-name of field> to obtain a specific field value
    // Sample API names: display_label, name

    // Obtaining specific field value of a role
    console.log(response.name); 

});
 
すべての権限の取得
              
              
//GET ALL PROFILES DATA

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};

crmclient.API.SETTINGS.getProfiles(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // Profiles data value available as JSON Array of the 'profiles' key of the JSON response
    // Each JSON object of the array corresponds to a profile

    response = JSON.parse(response.body);
    response = response.profiles;

    // For obtaining the entire response
    console.log(response);  


    // Iterating the JSON array to get individual profile details
    for(profile in response) {

        // Use response[profile].<api-name of field> to obtain a specific field value
        // Sample API names: description, name
        // List of all available keys of the response can be seen in the JSON object corresponding to
        // a record. The entire object containig all keys can be obtained using 'response[profile]'

        // Obtaining specific field value of a profile
        console.log(response[profile].name); 

        // Obtaining entire profile details
        console.log(response[profile]);  
    }
});
 
特定の権限の取得
              
              
//GET A SPECIFIC PROFILE DATA

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};
input.id = '3519112000000026011';   // id: profile-id
                                    // The profile-id of the specific profile

crmclient.API.SETTINGS.getProfiles(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // The profile data value is available as the first JSON object of the JSON Array
    // of the 'profiles' key of the JSON response

    response = JSON.parse(response.body);
    response = response.profiles[0];

    // For obtaining the entire profile details
    console.log(response);  

    // Use response.<api-name of field> to obtain a specific field value
    // Sample API names: description, name

    // Obtaining specific field value of a profile
    console.log(response.name); 

});
 
タブの項目の取得
              
              
//GET FIELDS DATA OF A MODULE

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};
input.module = 'Leads';

crmclient.API.SETTINGS.getFields(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // Fields data value available as JSON Array of the 'fields' key of the JSON response
    // Each JSON object of the array corresponds to a field

    response = JSON.parse(response.body);
    response = response.fields;

    // For obtaining the entire response
    console.log(response);  

    // Iterating the JSON array to get individual field details
    for(field in response) {
        console.log(response[field]);  
    }

});
 
すべてのタブレイアウトの取得
              
              
//GET ALL LAYOUTS DETAILS OF A MODULE

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};
input.module = 'Leads';

crmclient.API.SETTINGS.getLayouts(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // Layouts data value available as JSON Array of the 'layouts' key of the JSON response
    // Each JSON object of the array corresponds to a layout

    response = JSON.parse(response.body);
    response = response.layouts;

    // For obtaining the entire response
    console.log(response);  


    // Iterating the JSON array to get individual layout details
    for(layout in response) {

        // Use response[layout].<api-name of field> to obtain a specific field value
        // Sample API names: id, name
        // List of all available keys of the response can be seen in the JSON object corresponding to
        // a layout. The entire object containig all keys can be obtained using 'response[layout]'

        // Obtaining specific field value of a layout
        console.log(response[layout].name); 

        // Obtaining entire layout details
        console.log(response[layout]);  
    }
});
 
特定のレイアウトデータの取得
              
              
//GET A SPECIFIC LAYOUT DETAILS OF A MODULE

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};
input.module = 'Leads';
input.id = '3519112000000091055';   // id: layout-id
                                    // The layout-id of the specific layout

crmclient.API.SETTINGS.getLayouts(input).then(function(response) {
    
    // Response of the API call is returned in the 'body'

    // The layout data value is available as the first JSON object of the JSON Array
    // of the 'layouts' key of the JSON response

    response = JSON.parse(response.body);
    response = response.layouts[0];

    // For obtaining the entire layout details
    console.log(response);  

    // Use response.<api-name of field> to obtain a specific field value
    // Sample API names: id, name

    // Obtaining specific field value of a layout
    console.log(response.name); 

});
 
              
              
//GET RELATED LISTS DATA OF A PARTICULAR MODULE

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};
input.module = 'Leads';

crmclient.API.SETTINGS.getRelatedLists(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // Related lists data available as JSON Array of the 'related_lists' key of the JSON response
    // Each JSON object of the array corresponds to a related list item

    response = JSON.parse(response.body);
    response = response.related_lists;

    console.log(response);  

});
 
特定のタブのすべてのカスタムビューの取得
              
              
//GET ALL CUSTOM VIEWS OF A PARTICULAR MODULE

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};
input.module = 'Leads';

crmclient.API.SETTINGS.getCustomViews(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // Custom views data available as JSON Array of the 'custom_views' key of the JSON response
    // Each JSON object of the array corresponds to a custom view

    response = JSON.parse(response.body);
    response = response.custom_views;

    // For obtaining the entire response
    console.log(response);  

    // Iterating the JSON array to get individual custom view details
    for(custom_view in response) {

        // Use response[custom_view].<api-name of field> to obtain a specific field value
        // Sample API names: id, display_value
        // List of all available keys of the response can be seen in the JSON object corresponding to
        // a custom_view. The entire object containig all keys can be obtained using 'response[custom_view]'

        // Obtaining specific field value of a custom_view
        console.log(response[custom_view].display_value); 

        // Obtaining entire custom_view details
        console.log(response[custom_view]);  
    }

});
 
タブの特定のカスタムビューの取得
              
              
//GET A SPECIFIC CUSTOM VIEW DATA OF A MODULE

var crmclient = require('zcrmsdk');
crmclient.initialize();

var input = {};
input.module = 'Leads';
input.id = '3519112000000087511';   // id: custom-view-id
                                    // custom-view-id of the specific custom view

crmclient.API.SETTINGS.getCustomViews(input).then(function(response) {

    // Response of the API call is returned in the 'body'

    // The custom view data value is available as the first JSON object of the JSON Array
    // of the 'custom_views' key of the JSON response

    response = JSON.parse(response.body);
    response = response.custom_views[0];

    // For obtaining the entire custom_view details
    console.log(response);  

    // Use response.<api-name of field> to obtain a specific field value
    // Sample API names: id, display_value

    // Obtaining specific field value of a layout
    console.log(response.id); 

});