Monday, December 17, 2018

Add a Note on an Invoice when it is Printed using Workflow and SuiteScript

Add a Note on an Invoice when it is Printed using Workflow and SuiteScript

Create a Custom Workflow Action using the following snippet and name it "Set Print Date":

1. Create a .js file and paste the following code

var setPrintDate = function(){
 
 nlapiLogExecution('DEBUG', 'print log', nlapiGetRecordType() + ", "+ nlapiGetRecordId() + ", "+ 'memo' + ", "+ 'last printed on ' + ", "+ (new Date()))
 nlapiSubmitField(nlapiGetRecordType(), nlapiGetRecordId(), 'memo', 'mailed on ' + (new Date()));
 
}

2. Navigate to  Customization > Scripting > Scripts > New > Workflow Action

3. Write a Descriptive Name for the script(Set Print Date)

4. Upload the file from Step 1 under the Scripts > Script File field

5. Set the Function field to setPrintDate

6. Under the Deployments Tab, add a line and set the Applies To field to: Invoice

Create your Workflow

1. Navigate to  Customization > Workflow > Workflows > New

2. Under the Workflow Summary enter the following:

-----------------------------
  Record Type: Transaction
  Sub Types: Invoice
  Initiation:
    Event Based:
       On Update: checked
       Trigger Type: Before Record Load
       Event Type: Print
-----------------------------

3. Click new state from the left part of the Workflow Manager, enter a descriptive name and click save

4. Under the new state click new action

5. Pick the Workflow Action created from Above(Set Print Date) and Save

The Workflow will also execute when using Bulk Printing

No comments:

Post a Comment