gpt4 book ai didi

netsuite - 获取子列表行数据

转载 作者:行者123 更新时间:2023-12-02 20:47:04 25 4
gpt4 key购买 nike

如何从表单的子列表中检索所有数据?即,理想情况下,将子列表中的所有行检索为一个对象数组

/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*/

define(['N/ui/serverWidget',
'N/email',
'N/runtime',
'N/search',
'N/file',
'N/log'],

/**
* @param {ui} ui
* @param {email} email
* @param {runtime} runtime
* @param {search} search
* @param {file} file
* @param {log} log
*/
function(ui, email, runtime, search, file, log) {


function onRequest(context) {
// On GET I create a form and add a sublist inline editor to it.

if (context.request.method === 'POST') {
var sublistData = context.request.parameters.sublistdata;

// sublistData is not an array its funny string. See below:
// 2017-5-16\u000111\u00012017-5-19\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u00011\u0001\u0001Me\u0001\u0001\u0001\u0001\u00012\u0001\u0001F\u0001\u0001\u0001INSERT\u00011\u0001F\u0001\u0001\u0001\u0001\u0001\u00022017-5-22\u000111122122\u00012017-5-12\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u00011\u0001\u0001Me\u0001\u0001\u0001\u0001\u00012\u0001\u0001F\u0001\u0001\u0001INSERT\u00011\u0001F\u0001\u0001\u0001\u0001\u0001

//How can I get the sublist row data in a better format?
}
}

return {
onRequest: onRequest
};

});

最佳答案

发生的事情是 NetSuite 通过不可打印的 Unicode 控制字符 \u0001(字段之间)和 \u0002(行之间)分隔请求对象中的子列表值.

您可以使用 request.getLineCount()request.getSublistValue() 来检索结果。

var lines = context.request.getLineCount({ group: "sublist" });
for(var i = 0; i < lines; i++) {
var field1 = context.request.getSublistValue({ group: 'sublist', name: 'field1', line: i });
var field2 = context.request.getSublistValue({ group: 'sublist', name: 'field2', line: i });
}

关于netsuite - 获取子列表行数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43904481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com