netsuite保存了搜索多选下拉过滤器

时间:2015-11-17 15:11:42

标签: javascript netsuite suitescript

是否有人知道是否有办法在已显示已保存搜索的子列表中的套件中添加多选下拉过滤器。其中一列是“客户”,我想添加一个由子列表中的客户过滤的下拉列表。我已经有了代码设置,我只是想知道是否可以这样做。感谢

2 个答案:

答案 0 :(得分:1)

您可以将您的suitelet用作

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

答案 1 :(得分:0)

我通常只使用本机元素来处理这些事情,并以管理任何客户端交互的方式管理它们。我通常在我的suitelet代码中添加一个inlinehtml类型的字段,然后用客户端(字段更改和后期采购)事件和AJAX调用填充选择列表。