以下是使用自定义实体字段自动填充销售订单中字段的代码。
function exampleFieldChangedFunction(type, name, linenum){
if(name == 'entity'){ //this line will make sure that the field being changed is the 'customer' field
var customerValue = nlapiGetFieldValue('entity'); //the value of the customer field
var customerclassValue = nlapiLookupField('entity', customerValue, 'custentitykn_division_regions'); //Class value on the customer record
var customerClass = nlapiLookupField('custentitykn_division_regions', customerclassValue, 'class');
nlapiSetFieldValue('class', customerClass); //auto-populate Division/Region with the new customer's class value
}
}