<commit_before>/**
 * Module Description
 * 
 * Version    Date               Author                    Remarks
 * 1.00       17 Nov 2013     mohanboopalan
 *
 */

/**
 * The recordType (internal id) corresponds to the "Applied To" record in your script deployment. 
 * @appliedtorecord recordType
 * 
 * @param {String} type Operation types: create, edit, delete, xedit,
 *                      approve, cancel, reject (SO, ER, Time Bill, PO & RMA only)
 *                      pack, ship (IF only)
 *                      dropship, specialorder, orderitems (PO only) 
 *                      paybills (vendor payments)
 * @returns {Void}
 */
function userEventAfterSubmit(type){

var IsInclCustomField = true;
var IsCallSchedule = true; 

 if ( type == 'create')
  {
     var currentid = nlapiGetRecordId();
     var currentType = nlapiGetRecordType();
     var currentrecord = nlapiGetNewRecord();

     if (currentType == 'account' || currentType == 'department' || currentType == 'classification' || currentType == 'location' || currentType == 'subsidiary')
      {


               if (IsInclCustomField) { 
                  if (currentrecord.getFieldValue(GetInclCustomField(currentType)) == 'T' )
                  { IsCallSchedule = true;} else {IsCallSchedule = false;}
                }

              if (IsCallSchedule)
               {
               var params = new Array();
               params['custscript_acctsint_userrectype'] = GetSegmentId(currentType);
               params['custscript_acctsint_userrectypeid'] = currentid;
               params['custscript_acctsint_optype'] = 'create';
              var results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched', params);

                    if ( results != 'QUEUED' )
         {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched1', params);
                    if ( results != 'QUEUED' )
            {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched2', params);
                    if ( results != 'QUEUED' )
                {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched3', params);
                    if ( results != 'QUEUED' )
                    {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched4', params);

                        if (results != 'QUEUED')
                         {
	                  nlapiLogExecution('ERROR','Process Error',  'Will not be able to trigger event due to max simultaneous call');
                         }
                     }
                }
           }
       }




               }
        }
  } 
  if ( type == 'edit')
  {

     var currentType = nlapiGetRecordType();
      var newrecord = nlapiGetNewRecord();
      var oldrecord = nlapiGetOldRecord();
      var inclopttype = '';
      var IsCallSchedule = true;

     if (currentType == 'account' || currentType == 'department' || currentType == 'classification' || currentType == 'location' || currentType == 'subsidiary')
      {

                  if (IsInclCustomField) { 
                  if ((oldrecord.getFieldValue(GetInclCustomField(currentType)) == 'T' ) &&
                     (newrecord.getFieldValue(GetInclCustomField(currentType)) == 'F' ))
                     { inclopttype = 'edit-false';}
                  if ((oldrecord.getFieldValue(GetInclCustomField(currentType)) == 'F' ) &&
                     (newrecord.getFieldValue(GetInclCustomField(currentType)) == 'T' ))
                     { inclopttype = 'edit-true';}
                  if ((oldrecord.getFieldValue(GetInclCustomField(currentType)) == 'F' ) &&
                     (newrecord.getFieldValue(GetInclCustomField(currentType)) == 'F' ))
                     { IsCallSchedule = false;}
                 }


               var params = new Array();
               params['custscript_acctsint_userrectype'] =  GetSegmentId(currentType);
               params['custscript_acctsint_userrectypeid'] = newrecord.getId();

               if (( newrecord.getFieldValue('isinactive') != 'T' && oldrecord.getFieldValue('isinactive') == 'T' ) ||  
                   ( newrecord.getFieldValue('isinactive') == 'F' && oldrecord.getFieldValue('isinactive') != 'F' ) &&
                   (IsCallSchedule)) 
                  {

                      if  (inclopttype != '')
                      {
                       params['custscript_acctsint_optype'] = inclopttype;

                       }
                       else
                       {
                       params['custscript_acctsint_optype'] = 'edit-true';
                       }
                        
                    var results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched', params);
                    if ( results != 'QUEUED' )
         {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched1', params);
                    if ( results != 'QUEUED' )
            {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched2', params);
                    if ( results != 'QUEUED' )
                {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched3', params);
                    if ( results != 'QUEUED' )
                    {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched4', params);

                        if (results != 'QUEUED')
                         {
	                  nlapiLogExecution('ERROR','Process Error',  'Will not be able to trigger event due to max simultaneous call');
                         }
                     }
                }
           }
       }
                    //nlapiLogExecution('AUDIT','Queued',results);


      
                      //if ( newrecord.getFieldValue('parent') != '') 
                       //{
                       //     var filters = new Array();
                       //    filters[0] = new nlobjSearchFilter('isinactive',null,'is','F');
                       //    filters[1] = new nlobjSearchFilter('internalid',null,'is',newrecord.getFieldValue('parent'));
                       //   var searchresults = nlapiSearchRecord(currentType,null,filters,null);

                       //              for ( var i = 0;  i < searchresults.length; i++)
                       //              {
                       //      params['custscript_acctsint_userrectypeid'] = newrecord.getFieldValue('parent');
                       //var results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched', params);
                    //nlapiLogExecution('AUDIT','Queued',results);

                       //               }
                        //}
    
                }
              if (( newrecord.getFieldValue('isinactive') != 'F' && oldrecord.getFieldValue('isinactive') == 'F' ) || ( newrecord.getFieldValue('isinactive') == 'T' && oldrecord.getFieldValue('isinactive') != 'T' ) && (IsCallSchedule)) 
              {
                       if  (inclopttype != '')
                      {
                       params['custscript_acctsint_optype'] = inclopttype;
                       }
                       else
                       {
                       params['custscript_acctsint_optype'] = 'edit-false';
                       }

                        //var results;
                        //do 
                       //{

                    var results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched', params);
                    if ( results != 'QUEUED' )
         {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched1', params);
                    if ( results != 'QUEUED' )
            {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched2', params);
                    if ( results != 'QUEUED' )
                {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched3', params);
                    if ( results != 'QUEUED' )
                    {<commit_msg>commit latest changes to Accts Integration<commit_after>/**
 * Module Description
 * 
 * Version    Date               Author                    Remarks
 * 1.00       17 Nov 2013     mohanboopalan
 * 1.10       01 Feb 2014     mohanboopalan                Logic to include customfield or not
 */

/**
 * The recordType (internal id) corresponds to the "Applied To" record in your script deployment. 
 * @appliedtorecord recordType
 * 
 * @param {String} type Operation types: create, edit, delete, xedit,
 *                      approve, cancel, reject (SO, ER, Time Bill, PO & RMA only)
 *                      pack, ship (IF only)
 *                      dropship, specialorder, orderitems (PO only) 
 *                      paybills (vendor payments)
 * @returns {Void}
 */
function userEventAfterSubmit(type){

if (nlapiGetContext().getSetting('SCRIPT' , 'custscript_acctsint_isinclCustomField') == 'T' )
 {
     var IsInclCustomField = true;
 }
 else
 {  
     var IsInclCustomField = false;
 }

var IsCallSchedule = true; 

 if ( type == 'create')
  {
     var currentid = nlapiGetRecordId();
     var currentType = nlapiGetRecordType();
     var currentrecord = nlapiGetNewRecord();

     if (currentType == 'account' || currentType == 'department' || currentType == 'classification' || currentType == 'location' || currentType == 'subsidiary')
      {


               if (IsInclCustomField) { 
                  if (currentrecord.getFieldValue(GetInclCustomField(currentType)) == 'T' )
                  { IsCallSchedule = true;} else {IsCallSchedule = false;}
                }

              if (IsCallSchedule)
               {
               var params = new Array();
               params['custscript_acctsint_userrectype'] = GetSegmentId(currentType);
               params['custscript_acctsint_userrectypeid'] = currentid;
               params['custscript_acctsint_optype'] = 'create';
              var results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched', params);

                    if ( results != 'QUEUED' )
         {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched1', params);
                    if ( results != 'QUEUED' )
            {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched2', params);
                    if ( results != 'QUEUED' )
                {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched3', params);
                    if ( results != 'QUEUED' )
                    {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched4', params);

                        if (results != 'QUEUED')
                         {
	                  nlapiLogExecution('ERROR','Process Error',  'Will not be able to trigger event due to max simultaneous call');
                         }
                     }
                }
           }
       }




               }
        }
  } 
  if ( type == 'edit')
  {

     var currentType = nlapiGetRecordType();
      var newrecord = nlapiGetNewRecord();
      var oldrecord = nlapiGetOldRecord();
      var inclopttype = '';
      var IsCallSchedule = true;

     if (currentType == 'account' || currentType == 'department' || currentType == 'classification' || currentType == 'location' || currentType == 'subsidiary')
      {

                  if (IsInclCustomField) { 

                  if ((oldrecord.getFieldValue(GetInclCustomField(currentType)) == 'T' ) &&
                     (newrecord.getFieldValue(GetInclCustomField(currentType)) == 'F' ))
                     { inclopttype = 'edit-false';}

                  if ((oldrecord.getFieldValue(GetInclCustomField(currentType)) == 'F' ) &&
                     (newrecord.getFieldValue(GetInclCustomField(currentType)) == 'T' ))
                     { inclopttype = 'edit-true';}

                  if ((oldrecord.getFieldValue(GetInclCustomField(currentType)) == 'F' ) &&
                     (newrecord.getFieldValue(GetInclCustomField(currentType)) == 'F' ))
                     { IsCallSchedule = false;}

                 }


               var params = new Array();
               params['custscript_acctsint_userrectype'] =  GetSegmentId(currentType);
               params['custscript_acctsint_userrectypeid'] = newrecord.getId();

               if (( newrecord.getFieldValue('isinactive') != 'T' && oldrecord.getFieldValue('isinactive') == 'T' ) ||  
                   ( newrecord.getFieldValue('isinactive') == 'F' && oldrecord.getFieldValue('isinactive') != 'F' ) &&
                   (IsCallSchedule)) 
                  {
                      if  (inclopttype != '')
                      {
                       params['custscript_acctsint_optype'] = inclopttype;

                       }
                       else
                       {
                       params['custscript_acctsint_optype'] = 'edit-true';
                       }
                        
                    var results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched', params);
                    if ( results != 'QUEUED' )
         {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched1', params);
                    if ( results != 'QUEUED' )
            {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched2', params);
                    if ( results != 'QUEUED' )
                {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched3', params);
                    if ( results != 'QUEUED' )
                    {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched4', params);

                        if (results != 'QUEUED')
                         {
	                  nlapiLogExecution('ERROR','Process Error',  'Will not be able to trigger event due to max simultaneous call');
                         }
                     }
                }
           }
       }
                    //nlapiLogExecution('AUDIT','Queued',results);


      
                      //if ( newrecord.getFieldValue('parent') != '') 
                       //{
                       //     var filters = new Array();
                       //    filters[0] = new nlobjSearchFilter('isinactive',null,'is','F');
                       //    filters[1] = new nlobjSearchFilter('internalid',null,'is',newrecord.getFieldValue('parent'));
                       //   var searchresults = nlapiSearchRecord(currentType,null,filters,null);

                       //              for ( var i = 0;  i < searchresults.length; i++)
                       //              {
                       //      params['custscript_acctsint_userrectypeid'] = newrecord.getFieldValue('parent');
                       //var results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched', params);
                    //nlapiLogExecution('AUDIT','Queued',results);

                       //               }
                        //}
    
                }
              if ( newrecord.getFieldValue('isinactive') == 'T' && oldrecord.getFieldValue('isinactive') != 'T'  && (IsCallSchedule)) 
              {
                     
                       if  (inclopttype != '')
                      {
                       params['custscript_acctsint_optype'] = inclopttype;
                       }
                       else
                       {
                       params['custscript_acctsint_optype'] = 'edit-false';
                       }

                        //var results;
                        //do 
                       //{

                    var results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched', params);
                    if ( results != 'QUEUED' )
         {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched1', params);
                    if ( results != 'QUEUED' )
            {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched2', params);
                    if ( results != 'QUEUED' )
                {
results =  nlapiScheduleScript('customscript_acctsint_userevent_sched', 'customdeploy_acctsint_userevent_sched3', params);
                    if ( results != 'QUEUED' )
                    {
{'fraction_non_alphanumeric': 0.10590877677954388, 'fraction_numerical': 0.003167472932504031, 'mean_word_length': 1.744586691955113, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5975175', 'n_tokens_mistral': 4901, 'n_tokens_neox': 4552, 'n_words': 760}