netsuite - 使用 record.load() 加载子记录
问题描述
我在 Netsuite 中创建了两个具有父子关系的自定义记录。现在我想在 RESTlet 中使用 record.load() 方法加载子记录。当我使用 record.load() 时,它应该自己加载子记录。但不幸的是,事实并非如此。请有人告诉我我是否遗漏了什么。
function _get(context)
{
try
{
if(context.singleRecord == 'true')
{
if(context.recordType == 'customrecord418')
{
var project = record.load({
type: 'customrecord418',
id: context.id
});
if(context.forEdit == 'true')
{
log.debug({title:"project", details: project});
return {
id : project.getValue({fieldId: "id"}),
custrecord729 : project.getValue({fieldId: "custrecord729"}),
custrecord734 : project.getValue({fieldId: "custrecord734"}),
custrecord733 : project.getValue({fieldId: "custrecord733"}),
custrecord732 : project.getValue({fieldId: "custrecord732"}),
custrecord731 : project.getValue({fieldId: "custrecord731"}),
custrecord730 : project.getValue({fieldId: "custrecord730"}),
name : project.getValue({fieldId: "name"}),
projectPhases : null
}
}
else
{
var projectPhases = [];
var numLines = project.getLineCount({
sublistId: 'recmachcustrecord739'
});
if (numLines > 0)
{
for (var i = 0; i < numLines; i++)
{
projectPhases.push({
id : project.getSublistValue({
sublistId : 'recmachcustrecord739',
fieldId : 'id',
line : i
}),
custrecord736 : project.getSublistValue({
sublistId : 'recmachcustrecord739',
fieldId : 'custrecord736',
line : i
}),
custrecord737 : project.getSublistValue({
sublistId : 'recmachcustrecord739',
fieldId : 'custrecord737',
line : i
}),
custrecord738 : project.getSublistValue({
sublistId : 'recmachcustrecord739',
fieldId : 'custrecord738',
line : i
}),
custrecord739 : project.getSublistValue({
sublistId : 'recmachcustrecord739',
fieldId : 'custrecord739',
line : i
}),
name : project.getSublistValue({
sublistId : 'recmachcustrecord739',
fieldId : 'name',
line : i
})
});
}
}
return {
id : project.getValue({fieldId: "id"}),
custrecord729 : project.getValue({fieldId: "custrecord729"}),
custrecord734 : project.getValue({fieldId: "custrecord734"}),
custrecord733 : project.getValue({fieldId: "custrecord733"}),
custrecord732 : project.getValue({fieldId: "custrecord732"}),
custrecord731 : project.getValue({fieldId: "custrecord731"}),
custrecord730 : project.getValue({fieldId: "custrecord730"}),
name : project.getValue({fieldId: "name"}),
projectPhases : projectPhases
}
}
}
else
{
var project = record.load({
type: 'customrecord421',
id: context.id
});
return {
id : project.getValue({fieldId: "id"}),
custrecord736 : project.getValue({fieldId: "custrecord736"}),
custrecord737 : project.getValue({fieldId: "custrecord737"}),
custrecord738 : project.getValue({fieldId: "custrecord738"}),
custrecord739 : project.getValue({fieldId: "custrecord739"}),
name : project.getValue({fieldId: "name"})
}
}
}
else
{
const projectList = [];
var resultSet = search.load({
id: 'customsearch4629'
})
.run()
.getRange({
start: 0,
end: 100
});
for(var i=0; i<resultSet.length; i++){
projectList.push({
id : resultSet[i].getValue({name: "id"}),
custrecord729 : resultSet[i].getValue({name: "custrecord729"}),
custrecord734 : resultSet[i].getValue({name: "custrecord734"}),
custrecord733 : resultSet[i].getValue({name: "custrecord733"}),
custrecord732 : resultSet[i].getText({name: "custrecord732"}),
custrecord731 : resultSet[i].getValue({name: "custrecord731"}),
custrecord730 : resultSet[i].getValue({name: "custrecord730"}),
name : resultSet[i].getValue({name: "name"})
});
}
return projectList;
}
}
catch(ex)
{
return String(ex.message);
}
}
解决方案
您必须检查子记录中的允许子记录编辑首选项。
推荐阅读
- r - 在其他数据框的条件下将值添加到数据框中
- spring-boot - Springboot/Spring JPA - 具有多个 GetMapping 方法的控制器
- android - 如何将文件从 DOCUMENTS 文件夹复制到 Android 10 中应用的缓存文件夹?
- python - 无法阻止python在循环中遍历字符串
- python - 删除包含 txt 文件 python 中特定元素的行
- php - 我需要一个解决方案来从 php 中的总金额中找到成本价、税金、佣金
- angular - IdentityServer4 给出堆栈溢出错误
- blockchain - Chainlink中应用的白皮书中解释的链上架构在哪里?
- python - 使用 GPU 时,pytorch 中的 loss.backward() 停止响应
- javascript - 试图将我的工作代码变成一个函数