我想把这段代码上传到NetSuite
/**
* @NApiVersion 2.0
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/ui/dialog'],
function(dialog){
/**
* Validation function to be executed when sublist line is committed.
*
* @param {Object} context
* @param {Record} context.currentRecord - Current form record
* @param {string} context.sublistId - Sublist name
*
* @returns {boolean} Return true if sublist line is valid
*
* @since 2015.2
*/
function validadeRate(context){
try{
var currentRecord = context.currentRecord
var sublistName = context.sublistId
if(sublistname ==='expense'){
var categ = CurrentRecord.getCurrentSublistValue({
sublistId: sublistName,
fieldId: 'category'
})
if ((categ = 259) && (rate != 0.819)){
var currIndex = currentRecord.getCurrentSublistIndex({
sublistId: sublistName
})
currIndex +=1
var options = {
title : 'Rate Incorreto!',
message:'Por favor, verifique o valor informado no campo Rate na linha ' + currIndex + '.',
}
dialog.alert(options).then(function (result) { }).catch(function(result){})
return false
}
}
return true
}
catch(ex){
log.error('validateLine: ', ex.message)
}
}
return {
validadeRate : validadeRate
}
});
但是,当我试图上传到Netsuite文件时,我会收到这个错误:
注意到SuiteScript 2.0入口点脚本必须实现一个脚本类型函数。
这是一个功能的一部分,它将验证一个费用类别的费率。
我怎么才能解决这个问题?
提前谢谢!
发布于 2020-09-25 18:14:51
这是NetSuite的“入口点脚本验证”,因为它不包含预定义的入口点(事件)函数,因此脚本无效。这些职能是:
fieldChanged
lineInit
pageInit
postSourcing
saveRecord
sublistChanged
validateDelete
validateField
validateInsert
validateLine
您可以通过添加其中一个入口点来完成此验证和上载脚本,即使它什么也不做。例如,在function (dialog)
函数中可以添加一个pageInit()函数:
function pageInit(scriptContext) {}
并将返回块更改为:
return {
validadeRate : validadeRate,
pageInit: pageInit
}
现在它有了一个有效的入口点,并且验证应该通过。
然而,也许有一个更容易的方法。似乎(通过JSDoc块),每次添加子列表行时都会触发您的validadeRate
函数。这正是validateLine
入口点的作用所在。这样您就可以将返回块中的键更改为"validateLine“。
return {
validateLine: validadeRate
}
NetSuite知道每次添加一行时都要调用validadeRate
。
https://stackoverflow.com/questions/64066355
复制相似问题