这是我的 pageInit 函数
function poTransPageInit(type) {
// alert('page init');
var field= nlapiGetLineItemField('item', 'field');
field.isMandatory = true;
}
我在这里做错了什么?
这是我的 pageInit 函数
function poTransPageInit(type) {
// alert('page init');
var field= nlapiGetLineItemField('item', 'field');
field.isMandatory = true;
}
我在这里做错了什么?
确实 isMandatory 方法在客户端脚本中不可用。作为一种解决方法,您可以获得该字段的值并检查长度。
function validateLine(type){
if(type == 'sublistInternalID'){ //sublistInternalID = sublist internal id, i.e. 'item'
//get the sublist field value of mandatory column
var name = nlapiGetCurrentLineItemValue('line', 'fieldId'); //line = line #, fieldId = internal id of field
//if value length is greater than 0, then there is a value
if(name.length > 0){
return true;
} else {
alert('Please enter a value for Name field');
return false;
}
}
}
field.isMandatory
是 SuiteScript 2.0。在 SuiteScript 1.0 中,您将使用field.setMandatory(true)
,但显然该功能在客户端脚本中不可用。
您可以尝试将此逻辑移至用户事件脚本。