[英]NetSuite: Retrieve a value from a popup/subrecord
Thanks for clicking in.感谢您的点击。
On the Customer record within the Address subtab I have a sublist with addresses.在地址子选项卡中的客户记录中,我有一个包含地址的子列表。 On each line there's a button for edit .每行都有一个编辑按钮。 (See first picture) (见第一张图)
Clicking edit will bring up a popup window with some fields that can not be seen in Field Explorer.单击编辑将弹出一个弹出窗口 window,其中包含一些在 Field Explorer 中看不到的字段。 It is one of these fields I would really like to retrieve the value from.这是我真正想从中检索值的这些字段之一。 (See second picture) (见第二张图)
See the third picture to see how the record of the field I want to retrieve looks.看第三张图,看看我要检索的字段记录是什么样子的。
I've tried to both load the customer record
and to use lookupFields
.我尝试load the customer record
并使用lookupFields
。 But the field I want can't be accessed through just the customer record.但是我想要的字段不能仅仅通过客户记录访问。 Looking at the field record it says that it is for record of type Address .查看字段记录,它表示它用于Address类型的记录。 But it says it's a subrecord in record browser, and I don't really know how to access it.但它说这是记录浏览器中的子记录,我真的不知道如何访问它。
Do I need to create a search in order to get to it?我是否需要创建搜索才能找到它? Or is a better way to use SuiteQL?或者是使用 SuiteQL 的更好方法?
I'm still a bit new to NetSuite and haven't really done anything with SuiteQL yet.我对 NetSuite 还是有点陌生,还没有真正使用过 SuiteQL。 So any help and guidance is very much appreciated.因此,非常感谢任何帮助和指导。
Popup弹出窗口
There are different options.有不同的选择。
define(['N/record'], function(record) {
var myRecord = record.load({
type: record.Type.CUSTOMER,
id: INTERNALID_OF_YOUR_CUSTOMER
})
for (var line = 0; line < myRecord.getLineCount({}); line++) {
var address = myRecord.getSublistSubrecord({ sublistId: 'addressbook', line: line, fieldId: 'addressbookaddress' })
var accountNo = address.getValue({ fieldId: FIELDID_OF_YOUR_CUSTOM_FIELD })
}
})
define(['N/search'], function(search) {
var mySearch = search.create({
type: search.Type.CUSTOMER,
columns: [
'internalid',
'entityid',
'companyname',
{ join: 'Address', name: 'city' },
{ join: 'Address', name: FIELDID_OF_YOUR_CUSTOM_FIELD },
],
filters: [ 'internalid', search.Operator.IS, INTERNALID_OF_YOUR_CUSTOMER ]
})
mySearch.run().each(function(result) {
...DO SOMETHING
return true;
})
})
You need to load the subrecord for getting the values of address.You can use API recordObj.getCurrentSublistSubrecord .您需要加载子记录以获取地址的值。您可以使用 API recordObj.getCurrentSublistSubrecord 。 Here is the code how i have used to get the values:-这是我用来获取值的代码:-
1- First load the customer record in script. 1-首先在脚本中加载客户记录。
var customerObj = record.load({
type: record.Type.CUSTOMER,
id: customerRecordId,
isDynamic:true
});
var addressSubrecord = customerObj.getCurrentSublistSubrecord({
sublistId: 'addressbook',
fieldId: 'addressbookaddress'
});
addressSubrecord.getValue({
fieldId: 'addr1',
value: linedata1.address1
});
addressSubrecord.getText({
fieldId: 'country'
});
addressSubrecord.getValue({
fieldId: 'addr2'
});
addressSubrecord.getValue({
fieldId: 'zip'
});
2-Put inside for loop if it is according to line using API and add line as well. 2-如果根据使用 API 的行放入for 循环并添加行。
var numLines = objRecord.getLineCount({
sublistId: 'addressbook'
});
You can get all the data using their field id.您可以使用他们的字段 ID 获取所有数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.