netsuite 保存搜索多 select 下拉过滤器

netsuite saved search multi-select dropdown filter

有谁知道是否有办法在套件中添加多 select 下拉过滤器,该套件显示来自已保存搜索的子列表。其中一列是 "customer",我想添加一个下拉列表,按子列表中的客户进行过滤。我已经有了代码设置,我只是想知道这是否可以完成。谢谢

对于此类事情,我通常只使用原生元素,并按照您管理任何客户端交互的方式来管理它们。我通常在我的 suitelet 代码中添加一个 inlinehtml 类型的字段,然后用客户端(字段更改和 post 采购)事件和 AJAX 调用填充 select 列表。

您可以将您的套件用作

if (request.getMethod() == 'GET'){
    var field = form.addField('custpage_customers', 'multiselect', 'Customers');
var addedCustomers = [], selectedCustomers;

var searchResults= nlapiSearchRecord('transaction','customsearchID');;


//add customers options
searchResults.forEach(function(res){
 if(addedCustomers.indexOf(res.getValue('customer')) !== -1) return;
 field.addSelectOption(res.getValue('customer'), res.getText('customer'))
});

//filter sublists
//add customer options
if(request.getParameter('customerids')){
     addedCustomers = JSON.parse(request.getParameter('customerids'));
     searchResults = searchResults.filter(function(res){
       return addedCustomers.indexOf(res.getValue(customer)) !==-1)
     });

     //if above search result reduces your search results you may just want to re-run search as below than filtering it
    //searchResults = nlapiSearchRecord('transaction','customsearchID',['customer', 'anyof', JSON.parse(request.getParameter('customerids'))]);
}

//add sublist code goes here


//set a client script
form.setScript(MY_GLOBAL_CLIENT_SCRIPT)
 // set response 
}

然后编写一个将在字段更改时触发的全局客户端脚本

function FieldChanged(type, name)
{
    //  Prompt for additional information,  based on values already selected. 
    if ((name == YOUR_MULTISELECT_FIELD_ID)) 
    {
        //send AJAX with additional argument
        nlapiRequestURL(SUITELET_URL +  "&customerids=" +encodeURIComponent(JSON.stringify(nlapiGetFieldValue(YOUR_MULTISELECT_FIELD_ID))))
    }
}