Anurag Kumar
Anurag Kumar

Reputation: 195

Run After Submit Script when approve button is clicked Netsuite

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?

    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 && j < 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);
        }
      }
    }

    }

Upvotes: 0

Views: 1849

Answers (2)

CCC
CCC

Reputation: 379

If you're using the standard Approve button, you should be able to use context.type === 'approve' in a user event on after submit.

Upvotes: 0

Rusty Shackles
Rusty Shackles

Reputation: 2840

How is the approve button created? If it is created via workflow, you can use a custom workflow action script for this instead of an User Event script.

Upvotes: 1

Related Questions