Start a conversation

CRM.web v15.5: Show a MessageBox on FI Record Open When FI.7100 Is Empty or 0 (Use a Render Hook)

Contents

Overview

In ACRM (CRM.web) v15.5, a popup (MessageBox) may not appear when opening an FI record if the logic is implemented as a Hook Function / Field Hook. This is because Field Hooks are designed to run on field value changes and are not a reliable trigger for “on record open” behavior in CRM.web.

To reliably show a MessageBox when the FI Expand renders (for example, when FI field 7100 is empty or equals 0), implement the logic as a CRM.web Render Hook on FI.7100, ensure the field is included in the Expand field group, and ensure your custom JavaScript is loaded before the Expand renders.

Solution

Issue

A popup (MessageBox) should appear when opening an FI record in CRM.web if FI field 7100 is empty or 0, but earlier implementations did not trigger reliably on record open.

Environment

  • ACRM / CRM.web
  • Version: 15.5

Root cause

A Hook Function / Field Hook executes when a field value changes and is not a reliable “on record open” trigger in CRM.web. For “on open / on render” behavior, use a Render Hook.

Resolution (Render Hook approach)

1) Ensure FI.7100 is included in the FI Expand field group

Render Hooks are executed only if the field is part of the view configuration.

  • In CRM.designer, locate the FI Expand configuration / field group used in CRM.web.
  • Add FI field 7100 to the Expand field group (it can be visible or hidden).

2) Load your custom JavaScript in CRM.web

Ensure your custom JS file is loaded when the Expand renders (so the hook function exists).

  • Add your JS file (for example: custom-alerts.js) to the CRM.web custom scripting mechanism used by your system (per your standard web customization deployment).

3) Define a Render Hook on FI field 7100

In CRM.designer, set the Render Hook attribute on FI.7100 to call your function, for example:

u8.custom.Alerts.renderFIalerts($);

4) Implement the hook function (basic popup)

Example implementation:

u8.custom = u8.custom || {};
u8.custom.Alerts = u8.custom.Alerts || {};

u8.custom.Alerts.renderFIalerts = function ($) {
  var v = $.getValue(); // value of the current field (7100)
  v = (v === null || v === undefined) ? "" : String(v).trim();

  // Note: numeric values can arrive as text, e.g. "0"
  if (v === "" || v === "0") {
    u8.Base.Widgets.MessageBox.show({
      caption: "Attention",
      message: "Field 7100 is missing. Please complete it.",
      buttons: "Ok"
    });
  }
};

Prevent the popup from appearing multiple times (“show once per FI record”)

Render Hooks can execute more than once due to re-rendering. To show the message only once per FI record (but show it again when a different FI record is opened), add a guard stored on the current ExpandView, keyed by the current record UID.

u8.custom = u8.custom || {};
u8.custom.Alerts = u8.custom.Alerts || {};

u8.custom.Alerts.renderFIalerts = function ($) {
  var expandView = $u(".ExpandView", "current")[0];
  var uid = expandView.model.getUid();

  // Reset guard when navigating to a different FI record
  if (expandView._fiAlertUid !== uid) {
    expandView._fiAlertUid = uid;
    expandView._fiAlertShown = false;
  }

  // If already shown for this FI record, do nothing
  if (expandView._fiAlertShown) {
    return;
  }

  var v = $.getValue();
  v = (v === null || v === undefined) ? "" : String(v).trim();

  if (v === "" || v === "0") {
    expandView._fiAlertShown = true;

    u8.Base.Widgets.MessageBox.show({
      caption: "Attention",
      message: "Field 7100 is missing. Please complete it.",
      buttons: "Ok"
    });
  }
};

How to verify

  1. Open an FI record where field 7100 is empty → MessageBox appears once.
  2. Cause a re-render (for example, navigating within the Expand) → MessageBox does not appear again for the same record.
  3. Open a different FI record where field 7100 is empty or 0 → MessageBox appears again (once for that record).
  4. Open an FI record where field 7100 is populated with a non-zero value → No MessageBox appears.

Troubleshooting checklist (if it still does not work)

  • Confirm FI.7100 is included in the FI Expand field group used in CRM.web (even hidden is fine).
  • Confirm the custom JS file is actually loaded in CRM.web before the Expand renders.
  • Confirm the Render Hook is configured on FI.7100 and calls the correct function name/namespace.
  • If numeric comparisons behave unexpectedly, treat values as strings (for example, compare to "0").

Frequently Asked Questions

1. How do I recognize that I’m affected by this issue?
You expect a popup when opening an FI record (where FI.7100 is empty/0), but no popup appears. This commonly happens when using a Hook Function / Field Hook instead of a CRM.web Render Hook.
2. Why must FI field 7100 be included in the Expand field group?
Render Hooks run only for fields that are part of the view configuration. If FI.7100 is not included (visible or hidden), the Render Hook won’t execute and the value won’t be available via $.getValue().
3. Why do I need to compare against the string "0"?
$.getValue() returns field content as provided by the core, and numeric fields may be delivered as text (for example, "0"). Normalizing with String(v).trim() and comparing to "0" avoids type issues.
4. The MessageBox shows multiple times for the same record—how do I stop that?
Add a “show once” guard keyed by the FI record UID using expandView.model.getUid(), and store flags on the ExpandView (for example, _fiAlertUid and _fiAlertShown) so re-rendering does not retrigger the popup for the same record.
5. The popup never appears—what should I check first?
Check (1) FI.7100 is present in the FI Expand field group, (2) the custom JS is loaded in CRM.web, and (3) the Render Hook on FI.7100 calls the correct function/namespace.
Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Priyanka Bhotika

  2. Posted

Comments