0

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');
 }
}
MG2016
  • 289
  • 6
  • 32
  • Is your script deployment set to only run on Edit? That's the only reason I can think a UE wouldn't fire a create event, but I'm not familiar with the Revenue Element records yet. – erictgrubaugh May 04 '16 at 14:51
  • Actually it wasn't set to anything. I did try setting it with 'Create' but didn't work. – MG2016 May 04 '16 at 21:10
  • How is the creation of the Revenue Arrange (I think) record being triggered? Through the UI? – erictgrubaugh May 04 '16 at 22:46
  • Sorry but `revenueelement` doesn't seem to be a supported `Scriptable Sublist`. For more details on the Scripatable Sublist that supports `nlapiCommitLineItem` you can see Scriptable Sublists Overview in NS help docs. – Rockstar May 05 '16 at 04:39
  • @erictgrubaugh Correct, we can do this manually or set it up to run automatically by NetSuite. Manual approach: Transactions > Financials > Update Revenue Arrangements and Revenue Plans. Rockstar - it must be supported because the code does work - just requires a refresh when the revenue arrange record is created by NetSuite. – MG2016 May 05 '16 at 09:25
  • 1
    It is possible that NetSuite doesn't fire User Events when creating Revenue Plans, but I don't know that for sure. I would think creating it through the UI would work fine. I asked originally because if it was being created by another User Event script, then User Event scripts do not chain together. – erictgrubaugh May 05 '16 at 12:12
  • 1
    I found the issue. On the deployment file we need to set it to released for status and hit the Role checkbox. Presumably because the records are created by scheduled script by NetSuite. The system log shows that the user creating the record is bulk processing. – MG2016 May 05 '16 at 14:58
  • Ah, I should have thought of that after having you check the deployment Event type; glad you found your answer! – erictgrubaugh May 06 '16 at 13:14

0 Answers0