我们要求在订单项级别“对税前购买帐单应用折扣”。为此,我们在订单项级别创建了一个折扣字段。应根据“折扣”自定义字段中的值打折率。金额将根据数量和费率进行更新。
我已尝试使用工作流程,但它无法正常工作。任何人都可以帮助我编写脚本吗?
假设您将使用客户端脚本,则可以使用validateLine函数,该函数将在单击“项目子列表”上的“添加”按钮后触发。
function checkDiscount(type){
var getDiscount = nlapiGetCurrentLineItemValue('item', 'internalID of discount field');
var currRate = nlapiGetCurrentLineItemValue('item', 'rate');
var newRate = currRate * getDiscount; // depending on the value stored in Discount, you may need to modify this further
nlapiSetCurrentLineItemValue('item', 'rate');
return true;
}