How to Email the saved searches and reports to specific role users or dynamic Groups

Overview

By default, NetSuite does not support role-based emailing in Saved Searches or Reports. Additionally, dynamic groups are not supported in standard saved search email distribution.

To overcome this limitation, we can use a SuiteScript Map/Reduce script to generate and send search results to users belonging to specific roles or groups.

Solution

Approach

We achieve role-based or group-based email distribution by:

  1. Running the saved search through a Map/Reduce script.
  2. Formatting the results into a CSV or Excel file (or embedding directly into the email body).
  3. Sending the formatted results via email to users belonging to a specific role or group.

Map/Reduce Flow

  • GetInput Stage
  • Trigger the script and fetch the search based on the script deployment parameters.
  • Map Stage
  • Retrieve the search results and process each row individually.
  • Reduce Stage
  • Construct individual lines of the CSV file from the processed rows.
  • Summary Stage
  • Aggregate all CSV lines into a single file.
  • Send the final CSV (or inline results) as an email attachment/body to the target audience.

Parameters in Deployment

Each deployment of the script can be customized using deployment parameters:

  • Search to Run: Specify which saved search will be executed.
  • Recipient Group: Specify a static or dynamic group to which the results should be sent.

Handling Groups

  • Static Groups: Members can be directly retrieved from the group record (groupmembers sublist).
  • Dynamic Groups: Members are fetched by running the saved search linked to the group.

This ensures that the script can send emails to both static and dynamic groups seamlessly.

Benefits

  • Enables role-based or group-based emailing for saved search results.
  • Supports static and dynamic groups.
  • Provides flexibility to configure different saved searches and target groups per deployment.
  • Ensures search results can be shared in CSV, Excel, or inline email body formats.
  • Each deployment of this map reduce can be used for different saved searches.

With this approach, organizations can fully automate and customize saved search result distribution beyond the limitations of standard NetSuite emailing.

Leave a comment

Your email address will not be published. Required fields are marked *