Hi-
We are setting rev-rec on a line by line basis using RR schedules attached to the items. I am having a problem with my script... It is supposed to set rev-rec line by line for an order when you save (for lines where the item has a RR schedule attached)... Anyway, the RR start and end dates can be set by looping through the lines, selecting each line and using nlapiSetCurrentLineItemValue and then jumping to the next line (this works great)....
The problem is that I can not do this with the RR schedule (I am guessing that it has something to do with RR schedule being a drop-down, and not a date. I even moved the setting of the RR schedule to a second loop and it still does not work.... Anyway, the first line will set correctly, but then the script stops and the fist line remains selected (the item name is highlighted)...
I have tried adding nlapiCommitLineItem inside and outside of the loop to no avail, any help is appreciated....
-Matt Stryker
function addrr()
{
//GET SOME INFO FROM THE ORDER
var sotype = nlapiGetFieldValue('custbody_sotype');
var startdate = nlapiGetFieldValue('custbody_contractstartdate');
var enddate = nlapiGetFieldValue('enddate');
var Linenum = nlapiGetLineItemCount('item');
//LOOP #1-- SETS THE RevRec Start & End Dates for lines where the item has a RevRec schedule (works great)
for ( x = 1 ; x<= Linenum ; x++ )
{
var Currentline = x;
var descT = nlapiGetLineItemValue('item', 'item', Currentline);
var rrschedule = nlapiLookupField('item', descT, 'revrecschedule');
if (rrschedule==null)
worthless=1
else
{
nlapiSelectLineItem('item', Currentline);
nlapiSetCurrentLineItemValue('item', 'revrecstartdate', startdate, false);
nlapiSetCurrentLineItemValue('item', 'revrecenddate', enddate, false);
}
}
//COMMIT BECAUSE LOOP #1 LEAVES LAST LINE IN ORDER SELECTED...
nlapiCommitLineItem('item');
//LOOP #2-- should set the RevRec schedule if it exists for the item-- but it hangs after first line..
for ( x = 1 ; x<= Linenum ; x++ )
{
var Currentline = x;
var descT = nlapiGetLineItemValue('item', 'item', Currentline);
var rrschedule = nlapiLookupField('item', descT, 'revrecschedule');
if (rrschedule==null)
worthless=1
else
{
nlapiSelectLineItem('item', Currentline);
nlapiSetCurrentLineItemValue('item', 'revrecschedule', rrschedule, false);
nlapiCommitLineItem('item');
}
}
return true;
}