Hi all,
We have a scheduled script that was working prior to the last upgrade and now it throws an error whenever it tries to set a line item value on the component sublist of an assembly build:
SCRIPT SNIPETTE:
function DoAssemblyBuilds(itemRecord, locationGroup) { try { var itemId = itemRecord.getId(); var itemMembers = new Array(); var memberCount = itemRecord.getLineItemCount('member'); for (var memberLine = 1; memberLine <= memberCount; memberLine++) { var memberItemId = itemRecord.getLineItemValue('member', 'item', memberLine); var memberItemQty = itemRecord.getLineItemValue('member', 'quantity', memberLine); var memberCost = nlapiLookupField('item', memberItemId, 'cost'); itemMembers.push({ 'id': memberItemId, 'qty': memberItemQty, 'cost': memberCost }); } for (var locationIndex in locationGroup) { var qty = -1 * locationGroup[locationIndex]['locationQty']; try { if (qty > 0) { var assemblyBuildRecord = nlapiCreateRecord('assemblybuild'); var buildId = null; assemblyBuildRecord.setFieldValue('item', itemId); assemblyBuildRecord.setFieldValue('location', locationGroup[locationIndex]['location']); assemblyBuildRecord.setFieldValue('quantity', qty); assemblyBuildRecord.setFieldValue('date', Date()); assemblyBuildRecord.setFieldValue('memo', 'Software Assembly Auto-Build'); for (var memberIndex = 0; memberIndex < itemMembers.length; memberIndex++) { var memberLine = memberIndex + 1; var memberQty = itemMembers[memberIndex]['qty'] * qty; var memberUnitCost = itemMembers[memberIndex]['cost']; var memberItemCost = memberUnitCost * memberQty; assemblyBuildRecord.insertLineItem('component', memberLine); //FAILS ON THE FOLLOWING LINE AFTER UPGRADE //FAILS ON THE FOLLOWING LINE AFTER UPGRADE //FAILS ON THE FOLLOWING LINE AFTER UPGRADE assemblyBuildRecord.setLineItemValue('component', 'item', memberLine, itemMembers[memberIndex]['id']); assemblyBuildRecord.setLineItemValue('component', 'quantity', memberLine, memberQty); assemblyBuildRecord.setLineItemValue('component', 'unitcost', memberLine, memberUnitCost); assemblyBuildRecord.setLineItemValue('component', 'itemcost', memberLine, memberItemCost); } buildId = nlapiSubmitRecord(assemblyBuildRecord, true, false); if (buildId > 0) { var successMsg = 'Built ' + qty + ' '' + locationGroup[locationIndex]['name'] + '' at location '' + locationGroup[locationIndex]['location'] + '''; nlapiLogExecution('AUDIT', 'Assembly Build Successfull ', successMsg); } else { throw ('Submit failed.'); } } } catch (e) { var errormsg = 'DoAssemblyBuilds: Failed to build ' + qty + ' ' + locationGroup[locationIndex]['name']; errormsg += ' item(s) at location '' + locationGroup[locationIndex]['location'] + '''; nlapiLogExecution('ERROR', errormsg, e); } } } catch (ex) { nlapiLogExecution('ERROR', 'DoAssemblyBuilds', ex); } } ERROR:JavaException: com.netledger.core.scripting.NLServerSideScriptException: You have attempted an invalid sublist or line item operation. You are either trying to cannot access a field on a non-existent line or you are trying to add or remove lines from a static sublist.I'm assuming something has changed: Perhaps the "component" sublist is now read-only (that would be a problem), perhaps the setLineItemValue behavious has changed????Any help/insight would be helpful.Dennis