Application Module Display Data Hook

Overview

The getApplicationModuleDisplayData() hook allows you to customize how application module data is displayed on the Root management dashboard. This is useful when you need to calculate and display dynamic values (such as the current age of the policyholder), transform stored data into a more user-friendly format, or hide certain internal fields from the dashboard view.

By default, the application summary screen displays all data stored in the application.module object. This hook gives you control over what is displayed and how it is formatted, without affecting the underlying data stored on the application.

The hook is triggered automatically when an application is viewed on the Root management dashboard, provided both the feature flag and product module setting are enabled.

📘

Relationship to Policy Module Display Data Hook

This hook follows the same pattern as the getPolicyModuleDisplayData() hook, but operates on applications instead of policies. If you have already implemented the policy version, the application version works in exactly the same way.

Enabling the hook

Two configuration steps are required to enable this functionality:

Opt-in

As this is currently a beta feature, you will need to opt in to use this feature. Contact Root support to enable the override_application_module_display_data feature flag for your organisation.

Product module setting

In your product module's .root-config.json file, you need to enable the override setting:

{
  "productModuleName": "Root Funeral",
  "productModuleKey": "root_funeral",
  "organizationId": "00000000-0000-0000-0000-000000000001",
  "host": "http://localhost:4000",
  "stack": "root-node-20",
  "settings": {
    "overrideApplicationModuleDataDisplay": true,
    ...
  }
}

If either the feature flag or this setting is not enabled, the dashboard will display the standard application.module data without any transformation.

Configuring the getApplicationModuleDisplayData() function

The function should be defined in your product module code with the following signature:

function getApplicationModuleDisplayData(application, policyholder, currentUser) {
  // Custom logic
  return {
    display_data: { ... },
    module_data: { ... }
  };
}

Function parameters

The function accepts three parameters:

  • application - The complete application object, including all standard fields and the module object containing product-specific data.
  • policyholder - The policyholder object associated with the application.
  • currentUser - Optional. Information about the user currently viewing the application, including their user_id, email, and permissions.

Return value

The function must return an object with two properties:

  • display_data - Object. The data that will be displayed on the application summary screen. This can include calculated fields, formatted values, or a filtered subset of the module data.
  • module_data - Object. The underlying application module data. This is what will be used to populate any forms that rely on the module data.
{
  display_data: {
    // Data to be displayed on the dashboard
  },
  module_data: {
    // The underlying module data (typically application.module)
  }
}

Example: Calculating current age

This example shows how to calculate and display the policyholder's current age, even though only their date of birth is stored on the application.

function getApplicationModuleDisplayData(application, policyholder, currentUser) {
  // Calculate current age from date of birth
  const currentAge = policyholder.date_of_birth
    ? moment().diff(moment(policyholder.date_of_birth), "years")
    : application.module.age;

  return {
    display_data: {
      ...application.module,
      current_age: currentAge,
      source: "getApplicationModuleDisplayData",
    },
    module_data: application.module
  };
}

In this example:

  • The current age is calculated dynamically each time the application is viewed
  • All original module data is included in display_data via the spread operator
  • The module_data preserves the original application module for reference

Example: Filtering sensitive data

This example demonstrates how to hide certain internal fields from the dashboard view.

function getApplicationModuleDisplayData(application, policyholder, currentUser) {
  const { internal_notes, underwriting_score, risk_rating, ...publicData } = application.module;

  return {
    display_data: {
      ...publicData,
      cover_amount: application.module.cover_amount,
      monthly_premium: application.module.monthly_premium,
    },
    module_data: {
      ...application.module,
    },
  };
}

This approach removes items from the application display which do not need to be displayed on the dashboard, while keeping them in the underlying module_data should they need to be referenced in a form or any other dependency.

Example: Restricting data by user permissions

This example shows how to use the currentUser parameter to display different data depending on who is viewing the application.

function getApplicationModuleDisplayData(application, policyholder, currentUser) {
  const isAdmin = currentUser && currentUser.permissions.includes("admin");

  const displayData = {
    cover_amount: application.module.cover_amount,
    package_name: application.module.package_name,
  };

  if (isAdmin) {
    displayData.underwriting_score = application.module.underwriting_score;
    displayData.risk_rating = application.module.risk_rating;
  }

  return {
    display_data: displayData,
    module_data: application.module,
  };
}

How the data is displayed

The display_data object returned by your function is rendered on the application summary screen in a two-column table format. The data is automatically formatted by the Root dashboard:

  • Dates: ISO date strings are automatically formatted according to the organisation's date format preferences
  • Currency: Fields with names containing "premium", "amount", "value", "assured", "income", or "fund" are automatically formatted as currency with the application's currency symbol
  • Booleans: true displays as "Yes", false displays as "No"
  • Snake case: Field names like spouse_included are automatically converted to title case ("Spouse Included")
  • Nested objects: Object properties are rendered as nested tables for better organisation
  • Arrays: Arrays can be expanded/collapsed for better readability

You don't need to format these values yourself in the getApplicationModuleDisplayData() function—the platform handles formatting automatically.

📘

Automatic formatting

The Root dashboard automatically formats dates, currency amounts, and other common data types. You only need to return the raw values in your display_data object.

Error handling

The hook includes built-in error handling. If an error is thrown or occurs during execution, the dashboard will:

  1. Display an error message to the user: "Error getting application module data"
  2. Continue to display the rest of the application information normally

The error will be logged and displayed to the user, but will not prevent the application page from loading. This ensures that even if the display data calculation fails, users can still access and work with the application.

📘

Non-destructive display

The getApplicationModuleDisplayData() hook only affects how data is displayed on the dashboard. The underlying application data stored in application.module remains unchanged and is still accessible via the API.