0

这是我的 pageInit 函数

function poTransPageInit(type) {
    //   alert('page init');
    var field= nlapiGetLineItemField('item', 'field');
    field.isMandatory = true;
}

我在这里做错了什么?

4

2 回答 2

0

确实 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;
    }
  }
}
于 2021-05-19T00:06:18.607 回答
0

field.isMandatory是 SuiteScript 2.0。在 SuiteScript 1.0 中,您将使用field.setMandatory(true),但显然该功能在客户端脚本中不可用

您可以尝试将此逻辑移至用户事件脚本。

于 2021-05-18T17:12:09.000 回答