我一直试图将“发票”转换为“客户付款”而没有任何运气。这是我测试脚本时遇到的错误。
Account: 36714674
Environment: SandBox
Date & Time: 7/23/2017 8:37 am
Record Type: Sales Order
Internal ID: 697645
Execution Time: 0.00s
Script Usage: 0
Script: Tom Test Invoice
Type: User Event
Function: afterSubmit
Error: JS_EXCEPTION
{"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Please enter value(s) for: Project, Department","stack":["anonymous(N/recordService)","afterSubmit(/SuiteScripts/tom_test_1.js:47)"],"cause":{"type":"internal error","code":"USER_ERROR","details":"Please enter value(s) for: Project, Department","userEvent":"aftersubmit","stackTrace":["anonymous(N/recordService)","afterSubmit(/SuiteScripts/tom_test_1.js:47)"],"notifyOff":false},"id":"","notifyOff":false}
这是我的套件代码。
define(["N/log", "N/email", "N/record", "N/render"], function(log, email, record, render) {
function afterSubmit(scriptContext) {
var newOrder = scriptContext.newRecord.id;
var objRecord = record.transform({
fromType: record.Type.SALES_ORDER,
fromId: newOrder,
toType: record.Type.ITEM_FULFILLMENT
});
var fid = objRecord.save();
var objRecord2 = record.transform({
fromType: record.Type.SALES_ORDER,
fromId: newOrder,
toType: record.Type.INVOICE,
isDynamic: true,
});
var rid = objRecord2.save();
var objRecord3 = record.transform({
fromType: record.Type.INVOICE,
fromId: rid,
toType: record.Type.CUSTOMER_PAYMENT,
isDynamic: true,
});
var rid3 = objRecord3.save();
}
return {
afterSubmit: afterSubmit
};
});
正如您在我的代码中看到的,我首先从“销售订单”转换为“完整填充”,然后从“销售订单”转换为“ 发票“和”发票“到”客户付款“。
部分无效是从“发票”转换为“客户付款”
根据错误,我不知道如何以及在何处将“项目”和“部门”添加到我的代码中。
答案 0 :(得分:3)
您可以尝试使用function createSimpleForm()
{
var linkValidation=FormApp.createTextValidation().setHelpText('This must be a URL.').requireTextIsUrl().build();
var emailValidation=FormApp.createTextValidation().setHelpText('This must be a EMail.').requireTextIsEmail().build();
var ss=SpreadsheetApp.getActiveSpreadsheet();
var form=FormApp.create('Google Apps Script Question');
form.setDescription('A Simple Form to display my script editing problem.')
.setConfirmationMessage('Thanks. I\'ll be getting back to you at your email.')
.setAllowResponseEdits(true)
.setAcceptingResponses(false)
.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());
var containerLink=form.addTextItem();
containerLink.setTitle('Enter a URL')
.setValidation(linkValidation);
var clientEmail=form.addTextItem();
clientEmail.setTitle('Enter an email address')
.setValidation(emailValidation)
.isRequired();
}
选项:
ignoreMandatoryFields