On a Vendor Bill UE I’m trying to update an item l...
# suitescript
e
On a Vendor Bill UE I’m trying to update an item line field called “billreceipts” which would correspond to the Item Receipt Number from a saved search that grabs that value. It worked before (like early last year) in SB. The current SB has since been refreshed with all the “new stuff” like adding departments, project activity codes etc. Now it won’t update that field at all. The client script updates it when it fires and you go over each item line but as soon as you save it doesn’t keep the value. Anyone have any suggestions?
b
probably need a better explanation, you described it as both a user event and a client script
e
The UE script is not updating the field as expected.
var currRec = context.newRecord;
if (runtime.executionContext == runtime.ContextType.USER_INTERFACE) { var currRecId = currRec.getValue({ fieldId: ‘id’ }); var currType = currRec.getValue({ fieldId: ‘type’ }); log.debug(‘currType’, currType); log.debug(‘currRecId’, currRecId); if (currRecId != ‘’ && currType == ‘vendbill’) { var thisRecord = record.load({ type: ‘vendorbill’, id: currRecId, isDynamic: false, defaultValues: null }); var packingSlipNumber = thisRecord.getValue(‘custbody_olx_vend_order_number’); log.debug(‘Aftersubmit Packing Slip Number ’ + packingSlipNumber); var itemLineCount = thisRecord.getLineCount(‘item’); for (var i = 0; i < itemLineCount; i++) { var itemId = thisRecord.getSublistValue({ sublistId: ‘item’, fieldId: ‘item’, line: i }); var itemReceipt = getPackingSlips(itemId, packingSlipNumber); log.debug(‘Aftersubmit Found item receipt ’ + itemReceipt + ' for item ' + itemId); if (itemReceipt != ‘’) { thisRecord.setSublistValue({ sublistId: ‘item’, fieldId: ‘billreceipts’, value: itemReceipt, line: i }); log.debug(‘Updating line ’ + i); } } thisRecord.save(); } }
code is from aftersubmit event
b
i dont really think its sane to do this in an after submit, but the code looks like it could set the billreceipts
if you are sure the operation you are trying is possible, you should be trying to set the field in a less complicated script that just uses hardcoded values
e
it is possible because it worked before so i was just wondering why it doesn’t work anymore. this was in the aftersubmit only because it didn’t work in the beforesubmit. i’m not sure what you mean by a less complicated script that just uses hardcoded values.
b
dont use variables
hardcode everyhing