We have some code that is supposed to loop though and update line items on an Opportunity form. We believe the code was working the week of July 4th but have since noticed it’s failing. After troubleshooting it’s looking like the code is failing because nlapiSelectLineItem is not looping though line items, instead it gets stuck on the 1st line item. To prove it out, I created a simple loop and attached it to our test oppty form as a Page Init Function (code below). When this code executes the focus stays on the first line item every pass through the loop. I put in the alert(i) to confirm that the loop counter is incrementing correctly and that’s the case.
I then attached the same code as a custom button on the same oppty form and it works correctly there (loops through line items). I’ve also run it in firebug where it also works correctly.
Am I using the code correctly? Is there in issue with using nlapiSelectLineItem in client scripts attached to transaction forms? Has anyone else noticed similar behavior?
Note, I’ve tried executing the against orders with varying #’s of line items, and using IE and Firefox and observed the problem consistently.
Thanks,
--Shane
Loop Code:
function opptyFormLoad2()
{
var lineCount = nlapiGetLineItemCount('item');
alert('Exchange rate has changed. Please click OK to the following updates.');
for (var i = 1; i <= lineCount; i++)
{
nlapiSelectLineItem('item',i);
alert(i);
}
alert('Exchange rate update complete!');
}