NetSuite - BeforeSubmit not triggering on record creation
<p>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?</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function BeforeSubmit(type)
{

 var count = nlapiGetLineItemCount('revenueelement');
 nlapiLogExecution('DEBUG', 'Line Items', count);
 for (var x = 1; x &lt;= 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');
 }
}</code></pre>
</div>
</div>
</p>