# Workflow Action: Generate and Send ## Overview The **Generate and Send** workflow action allows you to automatically generate and dispatch outbound EDI transactions from Orderful Transaction records using NetSuite workflows. This provides a programmatic alternative to the manual "Generate And Send" button. ## Use Cases Use this workflow action to: * Automatically process outbound transactions when certain conditions are met * Trigger EDI generation as part of a larger business process workflow * Eliminate manual steps in your EDI transaction processing * Ensure transactions are sent immediately upon meeting specific criteria ## Supported Transaction Types This workflow action supports the following outbound transaction types: * 810 (Invoice) * 855 (Purchase Order Acknowledgment) * 856 (Ship Notice/Manifest) * 880 (Grocery Products Invoice) * 940 (Warehouse Shipping Order) * Simplified Invoice * Simplified Purchase Order Acknowledgment * Simplified Shipment Notice ## Prerequisites * The workflow action script must be deployed to your NetSuite account * Script ID: `customscript_orderful_generate_send_wa` * Deployment ID: `customdeploy_orderful_gen_send_wa` * The script must be in RELEASED status ## Setup Instructions ### 1. Deploy the Script The workflow action script should be automatically deployed when the Orderful bundle is installed. Verify deployment: 1. Navigate to **Customization > Scripting > Scripts** 2. Search for "Orderful | Generate and Send WA" 3. Verify the script status is **Released** 4. Check that the deployment is **Deployed** ### 2. Create or Edit a Workflow To add the Generate and Send action to a workflow: 1. Navigate to **Customization > Workflow > Workflows** 2. Create a new workflow or edit an existing one 3. Set the **Record Type** to **Orderful Transaction** 4. Add a workflow state where you want the action to execute ### 3. Add the Workflow Action Within your workflow state: 1. Click **Add Action** under the appropriate trigger type (e.g., After Field Edit, On Entry, etc.) 2. Select **Execute Script** as the action type 3. Configure the action: * **Script**: Select "Orderful | Generate and Send WA" * **Deployment**: Select "Orderful | Generate and Send WA" 4. Optionally add conditions to control when the action executes ### 4. Set Workflow Conditions (Optional) To ensure the action only runs for appropriate transactions, add conditions such as: * **Direction** = Outbound * **Document Type** is one of the supported types (810, 855, 856, etc.) * **Status** ≠ Success (to avoid reprocessing) * Any custom field criteria specific to your business logic ## Example Workflow Configuration ### Auto-Send on Transaction Creation This example automatically generates and sends transactions when they are created: **Workflow Settings:** * **Record Type:** Orderful Transaction * **Trigger:** After Record Submit * **Init On Create:** True **Workflow State:** * **Name:** Auto-Generate and Send * **Trigger Type:** On Entry **Workflow Action:** * **Type:** Execute Script * **Script:** Orderful | Generate and Send WA * **Conditions:** * Direction = Outbound * Document Type IN (810, 855, 856, 940, 880) ### Conditional Processing Based on Field Value This example only processes transactions when a custom checkbox is enabled: **Workflow Action Conditions:** * Direction = Outbound * Auto Send Enabled = True (custom field) * Status = Pending ## What the Action Does When executed, the workflow action: 1. Loads the Orderful Transaction record 2. Clears any previous error messages 3. Generates the EDI message payload based on linked NetSuite transactions 4. Dispatches the transaction to Orderful via API 5. Updates the transaction status and logs the result This is the same functionality as clicking the "Generate And Send" button manually. ## Error Handling If the workflow action encounters an error: * The error is logged to the script execution log (Debug level) * The error is written to the Orderful Transaction record * The workflow will halt or continue based on your workflow configuration * Check **Customization > Scripting > Script Execution Log** for detailed error information ## Troubleshooting ### Action Not Executing * Verify the script deployment is **Released** and **Deployed** * Check workflow conditions are being met * Review the workflow execution log * Ensure the user role has permission to execute the script ### Transaction Not Being Sent * Verify the transaction meets all requirements (ISA IDs, customer configuration, etc.) * Check the Orderful Transaction record for error messages * Review the script execution log for detailed error information * Ensure AutoSend is enabled or the appropriate conditions are met ### Duplicate Transactions * Add a condition to check transaction status before executing * Ensure workflow doesn't trigger multiple times for the same record * Use the transaction's existing flags to prevent reprocessing ## Best Practices 1. **Add Status Checks:** Always check that the transaction hasn't already been successfully sent 2. **Use Specific Conditions:** Only trigger on the document types you need 3. **Test in Sandbox:** Thoroughly test your workflow in a sandbox environment before deploying to production 4. **Monitor Execution:** Regularly review script execution logs during initial rollout 5. **Consider Timing:** Be mindful of when workflows trigger to avoid processing incomplete transactions