I created couple of date fields on an invoice line item as well as the Revenue Element entity. Next, I mapped these fields (Start and End dates) Setup > Accounting > Revenue Field Mapping. The fields correctly pickup the invoice line item start and end dates. Now I am trying to take those date values onto the Revenue Element standard start and end dates since these cannot be mapped as explained above. But my code only hits once the Revenue Arrange record / Element has been created and I edit > save. I have tried AfterSubmit and BeforeLoad with no luck. We shouldn't need to update the record for the fields to populate. Any ideas?
function BeforeSubmit(type)
{
var count = nlapiGetLineItemCount('revenueelement');
nlapiLogExecution('DEBUG', 'Line Items', count);
for (var x = 1; x <= count; x++)
{
nlapiSelectLineItem('revenueelement', x);
var startdate = nlapiGetCurrentLineItemValue('revenueelement', 'custcolstart_date_re');
var enddate = nlapiGetCurrentLineItemValue('revenueelement', 'custcolend_date_re');
nlapiLogExecution('DEBUG', 'Start Date', startdate);
nlapiLogExecution('DEBUG', 'End Date', enddate);
var revstartdate = nlapiSetCurrentLineItemValue('revenueelement', 'revrecstartdate', startdate);
var revenddate = nlapiSetCurrentLineItemValue('revenueelement', 'revrecenddate', enddate);
nlapiCommitLineItem('revenueelement');
}
}