我正在尝试创建一个带有子列表字段的自定义子列表,该子列表字段的来源是在设置>公司>国家/省/国家/地区部分中管理的国家记录。 这是我正在使用的示例代码,它无法正常工作。
_sublist.addField({
id: 'custpage_license_state,
type: serverWidgetModule.FieldType.SELECT,
label: 'LICENSE STATE',
source: 'state' //not recognizing record id
});
我尝试使用'state','states','-195',-195(能够找到这是我们实例“ -195”中的状态记录的内部ID),但是没有任何效果。< / p>
有人对如何进行这项工作有想法吗。
谢谢。
答案 0 :(得分:0)
州/省记录未公开。您需要手动将选项添加到<?php
require_once 'core/init.php';
include 'includes/head.php';
include 'includes/navigation.php';
include 'includes/headerpartial.php';
?>
<div class="col-md-12">
<h2 class="text-center">My Shopping Cart</h2><hr>
<div class="">
<?php if($cart_id == ''): ?>
<div class="" >
<p class="text-center text-danger">
Your shoppping cart is empty!
</p>
</div>
<?php else: ?>
<table class="table table-bordered table-condensed table-striped">
<thead><th>#</th><th>Item</th><th>Price</th><th>Quantity</th><th>Size</th><th>Sub Total</th></thead>
<tbody></tbody>
</table>
<?php endif; ?>
</div>
</div>
<?php
include 'includes/footer.php';
?>
中。您可以对客户记录执行搜索,该记录将仅返回当前分配的状态; </ p>
field
或者,在内存中创建一个客户,然后获取状态; (很抱歉,SS1代码,摘自SA 63293。)
/**
* Gets customers geographical states.
*
* @returns {Array} of state information.
*/
function getStates() {
var records = [];
var customerSearchObj = search.create({
type: "customer",
filters: [
["formulatext: {country}", "isnotempty", ""],
"AND",
["formulatext: {state}", "isnotempty", ""]
],
columns: [
search.createColumn({
name: "statedisplayname",
summary: "GROUP",
sort: search.Sort.ASC
}),
search.createColumn({ // abbreviation
name: "state",
summary: "GROUP"
})
]
});
customerSearchObj.run().each(function (result) {
var rec = {
state: result.getValue({name: 'state', summary: 'GROUP'}),
stateDisplay: result.getValue({name: 'statedisplayname', summary: 'GROUP'})
};
records.push(rec);
return true;
});
return records;
}
然后遍历结果,并使用function getAllStatesForCountry() {
var customer_record = nlapiCreateRecord('customer', {recordmode: 'dynamic'});
customer_record.selectLineItem('addressbook', 1);
var addrSubrecord = customer_record.createCurrentLineItemSubrecord('addressbook', 'addressbookaddress');
addrSubrecord.setFieldValue('country', 'GB');
var stateField = addrSubrecord.getField('dropdownstate');
return stateField.getSelectOptions();
}
将其添加到您的字段中。