Check out Oracle NetSuite upcoming events and conferences here
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Update your Profile with your Support type to get your Support Type badge.
Don't miss out on our Weekly Quiz! You only have until April 11, 2PM EST to comment your answers and earn rewards! Click here for more details.
Expand your NetSuite knowledge by joining our Ask A Guru Live sessions. RSVP on this event now.
Community Poll: What sort of content would you like to see more of?

How to Map the Invoice lines to its SO lines via SuiteScript 2.0?

edited Jun 30, 2023 6:00PM in Ask A Guru 7 comments

Hello. I'm running a script on the Invoice record. This script's aim is to take the value of the line field "custcol_altsales_invoice" from the invoice and map it to the corresponding SO line in a field called "custcol_ccaw_test_field_1". The issue is that this works if everything is invoiced at once (all the lines from the SO are present on the invoice). It will map incorrectly if, say, I only invoice some lines from the SO. Is there a way to map each line from the invoice to its exact line on the SO?

 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
define(['N/record'], function(record) {

  function updateCommissionOnSalesOrder(context) {
    //only run if it's edit or create
    if (context.type == 'create' || context.type == 'edit') {
      //reference the current invoice
var invoiceRecord = context.newRecord;
      // Get the Sales Order ID from the Invoice record's "Created From" field
      var salesOrderId = invoiceRecord.getValue({ fieldId: 'createdfrom' });
      // Get the line count on the Invoice record
      var lineCount = invoiceRecord.getLineCount({
        sublistId: 'item'

      // Update the "Commission Calculated" field on the

Howdy, Stranger!

Log In

To view full details, sign in.


Don't have an account? Click here to get started!


Community Whiz

Quarter 1 (Jan-Mar 2024)

This Week's Leaders

This Month's Leaders

All Time Leaders