Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda