如何使用 RESTlet 获取 Netsuite 中特定用户的联系人?

How to get contacts for the particular user in Netsuite using RESTlet?

管理员有 10 个联系人。其中一位用户有 15 个联系人。当我使用 RESTlet 获得单一联系人时,输出来了。但是当我获得所有联系人时,它无法获取所有联系人。正在尝试获取管理员的联系方式。

用户不应访问管理员帐户的联系人。它显示这样的错误,

[code] => INSUFFICIENT_PERMISSION

[message] => For security reasons, only an administrator is allowed to edit an administrator record.

i) 我想获取与管理员帐户无关的所有记录。

ii) 我只想获取与任何帐户无关的所有记录。

编码

function getAllIDs(datain) {
        var MAX_SIZE = typeof (datain.size) == 'undefined' ? 200 : datain.size;
        var INDEX = 0;
    
        if (typeof (datain.index) !== 'undefined') {
            INDEX = datain.index * MAX_SIZE;
            MAX_SIZE += INDEX;
        }
    
        var NS_filters = new Array();
    
        var columns = new Array();
        columns[0] = new nlobjSearchColumn('lastmodifieddate').setSort(1);
    
        var search = nlapiCreateSearch(datain.recordtype, NS_filters, columns)
        var results = search.runSearch();
        var records = results.getResults(INDEX, MAX_SIZE);
        return records;
    }
    
    function get_Allrecords(datain) {
        var all_IDs = getAllIDs(datain);
        var len = all_IDs.length;
        var result = new Array();
    
        for (var i = 0; i < len; i++) {
            result[i] = nlapiLoadRecord(all_IDs[i].getRecordType(), all_IDs[i].id)
        }
        return result;
    }

输入

$datastring = array('recordtype' => 'contact','size' => 100,'index'=>0);
$data_string = json_encode($datastring);

基于聊天讨论

1) you do not want to set execute as Role Administrator 2) issue is for contacts that has company field pointing to customers/partners.

错误不是由 RESTlet 或脚本引起的,更多是由于当前用户对所选联系人记录值公司的角色的限制。

请注意,限制可能是因为:

1) Department, class and Location (Department, class, location restriction on role) 2) Based on settings on role few employees have access to only those customers whom you are a sales rep of (Employee Restrictions on role)