Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Netsuite Field change function on LineItem is triggering 2 times

I am trying to archive the following

IF the lineitem,"custcol_celigo_sfnc_line_id"field matches the value "01t0g00000bx4WDAAY",then add date.

Here i am facing the issue,This record is triggering 2 times instead of one.

/**
 *@NApiVersion 2.x
 *@NScriptType ClientScript
 */
define(['N/record', 'N/search', 'N/url', 'N/https', 'N/runtime'], function(record, search, url, https, runtime) {

    function fieldChanged(context) {
    
        var currentRecord = context.currentRecord;
  
   
            var sublistName = context.sublistId;
            var sublistFieldName = context.fieldId;
   //  alert(JSON.stringify(currentRecord));
        //alert(JSON.stringify(context));
            var line = context.line;
      var start_Date="custcol_atlas_contract_start_date";
      var end_date="custcol_atlas_contract_end_date";
       if (sublistName === 'item') {
        if (sublistFieldName === 'custcol_celigo_sfnc_line_id')
        {
              var value = currentRecord.getCurrentSublistValue({
                            sublistId: sublistName,
                            fieldId: sublistFieldName
                        })
if(value!="01t0g00000bx4WDAAY"||value!="01t70000004b5TWAAY"||value!="01t70000004b6LZAAY"||value!="01t0g00000Z9ryHAAR"||value!="01t0g00000Z9ryCAAR"||value!="01t0g00000aYySFAA0"||value!="01t0g00000aZJyRAAW")
  {
       
                if(value=="01t0g00000bx4WDAAY")
                  {
                  //  alert("Triggered");
                         var stdate = currentRecord.getCurrentSublistValue({
                            sublistId: sublistName,
                            fieldId: start_Date
                        })
                         
                         var newDate = new Date(stdate.setMonth(stdate.getMonth()+1));
                   
                            currentRecord.setCurrentSublistValue({
                            sublistId: sublistName,
                            fieldId: start_Date,
                            value: newDate
                        });
                  }
            
           
            
            
  
        }
              
        }
       }
            return true;
    }
    var exports = {};


    exports.fieldChanged = fieldChanged;

    return exports;
});


This script is triggering 2 times, so its adding double. How to make it to trigger one time?

Thanks in advance

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I don't think the script can trigger twice. Are you getting the "Triggered" alert twice?

/**
 *@NApiVersion 2.x
 *@NScriptType ClientScript
 */
define(['N/record', 'N/search', 'N/url', 'N/https', 'N/runtime'], function(record, search, url, https, runtime) {

    function fieldChanged(context) {
    
        var currentRecord = context.currentRecord;
  
   
            var sublistName = context.sublistId;
            var sublistFieldName = context.fieldId;
   //  alert(JSON.stringify(currentRecord));
        //alert(JSON.stringify(context));
            var line = context.line;
      var start_Date="custcol_atlas_contract_start_date";
      var end_date="custcol_atlas_contract_end_date";
       if (sublistName === 'item') {
        if (sublistFieldName === 'custcol_celigo_sfnc_line_id')
        {
              var value = currentRecord.getCurrentSublistValue({
                            sublistId: sublistName,
                            fieldId: sublistFieldName
                        })
if(value!="01t0g00000bx4WDAAY"||value!="01t70000004b5TWAAY"||value!="01t70000004b6LZAAY"||value!="01t0g00000Z9ryHAAR"||value!="01t0g00000Z9ryCAAR"||value!="01t0g00000aYySFAA0"||value!="01t0g00000aZJyRAAW")
  {
       
                if(value=="01t0g00000bx4WDAAY")
                  {
                  //  alert("Triggered");
                         var stdate = currentRecord.getCurrentSublistValue({
                            sublistId: sublistName,
                            fieldId: start_Date
                        })
                         
                         var newDate = new Date(stdate.setMonth(stdate.getMonth()));
                   
                            currentRecord.setCurrentSublistValue({
                            sublistId: sublistName,
                            fieldId: start_Date,
                            value: newDate
                        });
                  }
            
           
            
            
  
        }
              
        }
       }
            return true;
    }
    var exports = {};


    exports.fieldChanged = fieldChanged;

    return exports;
});

Try the above code once. Let me know the updates in comments below.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!