当前的问题是我不能提交行项目。即使item是唯一需要的字段,我也需要添加更多字段吗?
function OLDcreateTO() //(request, response)
{
for ( var i = 1; i < lines + 1 ; i++ )
{
nlapiLogExecution('DEBUG','<Before Load Script> type: '+type,"line # " + i);
arrayName[i] = PORecord.getLineItemValue('item', 'item', i );
nlapiLogExecution('DEBUG','<Before Load Script> type: '+type, arrayName[i]);
}
nlapiLogExecution('DEBUG','<Before Load Script> type: '+type, lines + ' lines');
var TOrecord = nlapiCreateRecord ('transferorder');
var TOrecordID = TOrecord.getId();
TOrecord.setFieldValue('customform',128);
//subsidiaries CC bedford id is 2
TOrecord.setFieldValue('subsidiary',2);
//testing for location and transfer location, 144 & 145
TOrecord.setFieldValue('location',144);
TOrecord.setFieldValue('transferlocation',145);
nlapiLogExecution('DEBUG','<Before Load Script> type: '+type, 'break 4');
// add new lines to a sublist
nlapiSelectNewLineItem('item');
// set the item and location values on the currently selected line
nlapiSetCurrentLineItemValue('item', 'item', arrayName[1]);
nlapiSetCurrentLineItemValue('item', 'location', 6);
// commit the line to the database
nlapiCommitLineItem('item');
nlapiLogExecution('DEBUG','<Before Load Script> type: '+type, 'break 5');
var TOResult = nlapiSubmitRecord(TOrecord, true, true);
var TOTranID= nlapiLookupField('transferorder', TOResult, 'tranid');
nlapiLogExecution('DEBUG','<Before Load Script> type: '+type, 'break 6');
var poURL = nlapiResolveURL('RECORD', 'transferorder', TOResult);
nlapiSetRedirectURL('RECORD','transferorder', TOResult);
}因此,我尝试通过PO上的按钮将采购订单的项目填充到新的转移订单上的项目字段中。在此基础上,用户可以在提交和创建之前对记录进行任何更改。主要的问题是我不知道如何填充一个空白的from脚本。我让它通过url字符串重定向到那里,但我相信有更好的方法。
总而言之。
-User在采购订单上单击"create TO“按钮
-takes用户转到"create TO“页面,其中根据PO预先填充了所有项目(以及一些不同的信息)。
-User编辑该记录,然后提交它。
suitescript 1.0 //create_to_button
var newId ;
var newType ;
function beforeload(type)
{
if(nlapiGetContext().getRole() == '3')
{
if(type =='view' || type == 'edit')
{
newId = nlapiGetRecordId();
newType = nlapiGetRecordType();
if(newType == 'purchaseorder')
{
var strURL = "https://system.na2.netsuite.com/app/accounting/transactions/trnfrord.nl"
var scriptbutton = 'window.open(' + String.fromCharCode(39) + strURL + String.fromCharCode(39) + ')' ;
//nlapiLogExecution('DEBUG','<Before Load Script> type: '+type, 'URL: '+strURL + '&id=' + newId);
form.addButton('custpage_createpo', 'Create TO', scriptbutton);
}
}
}
}
function loadTO() //(request, response)
{
nlapiLogExecution('DEBUG','<Before Load Script> type: '+type, 'hello');
nlapiLoadRecord(newType, newId);
}任何想法或建议都是值得感谢的。-Brandon
发布于 2018-05-08 00:03:12
如果您知道收件人将被保存,您可以打开一个套件,该套件将填充收件人。保存它并重定向到新的使用带有来自nlapiResolveURL的url的nlapiSetRedirect。
如果TO可能无法保存,则向您已经使用的tasklink url添加一些参数,并将您的填充逻辑添加到to的客户端init函数。您可能需要使用beforeLoad用户事件脚本将一些自定义字段添加到to中,以提供客户端脚本所需的信息。(您的客户端脚本也可以查看查询字符串参数,但根据您所做的操作,服务器端查找可能会更快)。
https://stackoverflow.com/questions/50217577
复制相似问题