有谁知道是否有一种方法可以在显示现有已保存搜索的子列表的套件中添加多选下拉过滤器。其中一列是“客户”,我想添加一个下拉列表,按子列表中的客户进行过滤。我已经设置了代码,我只是想知道这是否可以完成。谢谢
2812 次
2 回答
1
您可以将套件用作
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))))
}
}
于 2015-11-17T17:22:23.560 回答
0
我通常只使用本机元素来处理此类事情,并以管理任何客户端交互的方式管理它们。我通常在我的套件代码中添加一个 inlinehtml 类型的字段,然后使用客户端(字段更改和后采购)事件和 AJAX 调用填充选择列表。
于 2015-11-17T16:40:59.937 回答