我正在尝试创建库存调整用户事件脚本。但是,我无法创建创建记录后发生的GL影响。为了触发总帐影响,我正在按脚本设置“估计总价值”字段,但出现错误消息“交易不平衡”。但是,当我手动执行此操作时,我将通过脚本设置的估计总值中设置了相同的金额
function create_inv_adjustment(fromlocation,adjAccount,objRecord,nRecType)
{
log.debug('create_inv_adjustment','entry');
var count = objRecord.getLineCount('custpage_itemsublist');
log.debug('create_inv_adjustment','lineCount : '+count);
var new_inv_adjustment = record.create({ type: record.Type.INVENTORY_ADJUSTMENT, isDynamic: true })
new_inv_adjustment.setValue({ fieldId:'account', value: adjAccount })
new_inv_adjustment.setValue({ fieldId:'adjlocation', value: fromlocation })
if(count > 0)
{
var estimatedtotalvalue = 0;
for(i=0; i<count; i++)
{
var item = objRecord.getSublistValue({
sublistId : 'custpage_itemsublist',
fieldId : 'custpage_item',
line : i });
log.debug('create_inv_adjustment','itemName : '+item);
var quantity = objRecord.getSublistValue({
sublistId : 'custpage_itemsublist',
fieldId : 'custpage_quantity',
line : i });
log.debug('create_inv_adjustment','itemquantity : '+quantity);
var description = objRecord.getSublistValue({
sublistId : 'custpage_itemsublist',
fieldId : 'custpage_description',
line : i });
if(quantity == '' || quantity == null)
{}
else
{
new_inv_adjustment.selectNewLine({
sublistId: 'inventory'
});
new_inv_adjustment.setCurrentSublistValue({
sublistId: 'inventory',
fieldId: 'item',
value: item ,ignoreFieldChange:true });
new_inv_adjustment.setCurrentSublistValue({
sublistId: 'inventory',
fieldId: 'adjustqtyby',
value: quantity ,ignoreFieldChange:true });
new_inv_adjustment.setCurrentSublistValue({
sublistId: 'inventory',
fieldId: 'description',
value: chkNull(description) ,ignoreFieldChange:true });
new_inv_adjustment.setCurrentSublistValue({
sublistId: 'inventory',
fieldId: 'location',
value: chkNull(fromlocation),ignoreFieldChange:true });
new_inv_adjustment.commitLine({
sublistId: 'inventory'
});
}
}
}
var save = new_inv_adjustment.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
log.debug('create_inv_adjustment','inv-adj saved : '+save);
}
目前,只有In-adjustment不受GL影响。我可以改用suiteGL吗?
在通过脚本创建库存调整时,在线级上设置单位成本字段,这将在创建该记录后产生总帐影响。