我正在尝试创建库存调整用户事件脚本。但是,我无法执行创建记录后发生的GL影响。要触发GL影响,我正在通过脚本设置Estimated Total Value字段,但我收到一个错误消息"Transaction is not balanced“。但是,当我手动操作时,在脚本设置的估计总值中设置了相同的数量
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);
}目前,只有存货调整不受总账影响。我可以改用suiteGL吗?
发布于 2020-04-02 14:52:18
通过脚本创建库存调整时,在创建该记录后将对总帐产生影响的行级别中设置单位成本字段。
https://stackoverflow.com/questions/60885764
复制相似问题