将请求放在多个记录上的REST脚本
我有一个REST脚本,目前在单次录像带请求中运行良好。我正在寻找更新脚本,以便它可以支持多记录更新。
当前脚本:
function put(context) {
// doValidation([context.recordtype, context.id], ['recordtype', 'id'], 'PUT');
var rec = record.load({
type: context.recordtype,
id: context.id
});
var values = context.values;
for (var fldName in values) {
if (values.hasOwnProperty(fldName)) {
rec.setValue({
fieldId: fldName,
value: values[fldName]
});
}
}
rec.save({
ignoreMandatoryFields: true
});
rec = record.load({
type: context.recordtype,
id: context.id
});
return rec; // reloading includes the results of any triggered actions.
}
return {
post: postProcess,
put: put
};
工作单记录JSON主体有效载荷的PUT请求:
{
"recordtype": "customrecord_record",
"id": "201",
"values": {
"custrecord_managementpriority": "3"
}
理想情况下寻找支持此有效负载结构的PUT脚本:(
{
"recordtype": "customrecord_record",
"id": "201",
"values": {
"custrecord_managementpriority": "3"
}
},
{
"recordtype": "customrecord_record",
"id": "204",
"values": {
"custrecord_managementpriority": "4"
}
}
包裹在[]或当然是必要的)。
I have a REST script that's currently working well for single-record PUT requests. I'm looking to update the script such that it can support multi-record updates.
Current Script:
function put(context) {
// doValidation([context.recordtype, context.id], ['recordtype', 'id'], 'PUT');
var rec = record.load({
type: context.recordtype,
id: context.id
});
var values = context.values;
for (var fldName in values) {
if (values.hasOwnProperty(fldName)) {
rec.setValue({
fieldId: fldName,
value: values[fldName]
});
}
}
rec.save({
ignoreMandatoryFields: true
});
rec = record.load({
type: context.recordtype,
id: context.id
});
return rec; // reloading includes the results of any triggered actions.
}
return {
post: postProcess,
put: put
};
Working Single Record JSON body payload for PUT request:
{
"recordtype": "customrecord_record",
"id": "201",
"values": {
"custrecord_managementpriority": "3"
}
Ideally looking for the PUT script to support this payload structure:
{
"recordtype": "customrecord_record",
"id": "201",
"values": {
"custrecord_managementpriority": "3"
}
},
{
"recordtype": "customrecord_record",
"id": "204",
"values": {
"custrecord_managementpriority": "4"
}
}
(Wrapped in [ ] or however necessary of course).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决。如果其他人遇到此问题,将留下这篇文章。这件作品预先做到了:
Solved. Will leave this post up in case anyone else runs into this issue. This piece upfront did the trick: