title: Run After Submit Script when approve button is clicked Netsuite
body: <p>When approve button is clicked on journal entry, this reversal should be auto approved. This script is running when i am clicking edit and then saving. I want this to run when just approve button is clicked without editing. How can i do that?</p>
  
  <pre><code>    function JEReversalAfterSubmit(type){
  
      if (type == 'approve')
     {
              var filters2 = new Array();
              filters2[0] = new nlobjSearchFilter( 'tranid', null, 'is', 'JV267');
              var columns2 = new Array();
              columns2[0] = new nlobjSearchColumn( 'internalid' );
              var searchresults2 = nlapiSearchRecord( 'journalentry', null, filters2, columns2 );
  
              for ( var j = 0; searchresults2 != null &amp;&amp; j &lt; searchresults2.length; j++ )
              {
                  var searchresult2 = searchresults2[ j ];
                  var reversalJEID = searchresult2.getValue( 'internalid' );
                  nlapiLogExecution('debug','reversalJEID',reversalJEID);
              }
  
              nlapiLogExecution('DEBUG','34','34');
  
              var params = new Array();
              params['type'] = 'approve';
              nlapiSetRedirectURL('RECORD','journalentry',reversalJEID, 'false',params);
          }
        }
      }
  
      }
  </code></pre>