Custom JavaScript for lead conversion popup not executing in production

We have custom JavaScript that modifies the lead conversion popup to auto-populate certain fields based on the lead source. It works perfectly in our test environment, but in production, the custom JS isn’t executing at all. The lead conversion process completes, but our custom field population logic never runs, causing conversion errors when required fields are left empty.

Here’s the initialization code:

ZOHO.embeddedApp.on('EntityAction', function(data) {
  if (data.Entity === 'Leads' && data.Action === 'Convert') {
    populateConversionFields();
  }
});

I’ve confirmed the widget is properly installed in production and the EntityAction event is supposed to trigger when the conversion popup opens. The Widget SDK loads successfully (I can see it in the network tab), but the event handler never fires. This is critical because our sales team relies on these auto-populated fields during lead conversion, and without them, the conversion workflow is broken. Has anyone experienced issues with Widget SDK event handling specifically for lead conversion lifecycle events or popup customization in Zoho 2021?

You’re encountering a complex issue that involves Widget SDK event handling, the lead conversion lifecycle, and popup customization in Zoho 2021. Let me break down the solution systematically.

Widget SDK Event Handling Issue: The EntityAction event in Zoho 2021 has timing and scope limitations, especially for lead conversion. The event doesn’t reliably fire for conversion actions because the conversion popup is rendered in a separate context from the main page where your widget is loaded. Here’s what’s actually happening:

  1. Your widget loads on the Leads detail page
  2. User clicks ‘Convert Lead’
  3. Zoho opens the conversion popup in a modal/iframe
  4. Your EntityAction listener is on the parent page, not in the popup context
  5. The event either doesn’t fire or fires too late to affect the popup

Lead Conversion Lifecycle: The lead conversion process in Zoho CRM follows this sequence:

  • User initiates conversion (button click)
  • System validates lead data
  • Conversion popup renders with Account, Contact, and Deal forms
  • User fills in additional fields
  • System creates related records and marks lead as converted

Your custom JavaScript needs to intercept this process at step 3, but Widget SDK events aren’t designed for popup-level interactions.

Popup Customization Solution: For reliable lead conversion customization in Zoho 2021, you need to use a different approach:

// Instead of EntityAction, use PageLoad with DOM observation
ZOHO.embeddedApp.on('PageLoad', function(data) {
  observeConversionPopup();
});

function observeConversionPopup() {
  const observer = new MutationObserver(function(mutations) {
    const popup = document.querySelector('[data-zcqa="lead_convert_popup"]');
    if (popup) {
      populateConversionFields();
      observer.disconnect();
    }
  });
  observer.observe(document.body, { childList: true, subtree: true });
}

However, this approach has limitations because of iframe isolation.

Recommended Alternative Approach: Given the constraints of Zoho 2021’s Widget SDK with popup interactions, the most reliable solution is to use Workflow Rules with Field Update actions instead:

  1. Create a workflow that triggers on Lead Status = ‘Converted’
  2. Use custom functions to populate the required fields on the newly created Account/Contact/Deal records
  3. This ensures fields are populated regardless of how the conversion happens

If you absolutely need to modify the conversion popup UI, consider:

Option 1: Custom Button Approach Replace the standard Convert button with a custom button that:

  • Collects necessary data
  • Pre-populates fields using API calls
  • Then triggers the standard conversion

Option 2: Client Script (if available in your Zoho plan) Client Scripts have better integration with popup contexts:

  • Create a Client Script for Leads module
  • Use ‘Before Convert’ event type
  • Implement field population logic there

Production vs Test Environment Differences: The reason it works in test but not production likely relates to:

  • Different widget installation states (test might have an older, working version)
  • Cached JavaScript in test environment
  • Different security policies or user permissions
  • API rate limiting or connection scope differences

To troubleshoot the production issue specifically:

  1. Open browser DevTools and go to Console tab
  2. Manually execute: `ZOHO.embeddedApp.emit(‘test’, {data: ‘test’})
  3. If this fails, the Widget SDK isn’t properly initialized
  4. Check Network tab for failed widget resource loads
  5. Verify the widget’s OAuth connection is active in production

Immediate Workaround: While you implement a proper solution, create a validation rule on the Account/Contact/Deal modules that checks for the required fields. This will at least prevent incomplete conversions and prompt users to fill in the missing data, even if it’s not auto-populated.

For long-term stability, I strongly recommend moving away from Widget SDK event handling for lead conversion customization and instead using workflow-based field updates or custom button implementations that give you more control over the conversion process.

The lead conversion popup in Zoho CRM is actually an iframe, and Widget SDK events don’t always propagate correctly into iframes. You might need to use postMessage or inject your script directly into the popup context. This is a known limitation of the Widget SDK when dealing with modal popups.

Have you checked the browser console for any JavaScript errors in production? Sometimes there are conflicts with other scripts or browser extensions that prevent your widget code from executing. Also, make sure the widget is actually loaded on the Leads module page in production - check the widget installation settings to confirm it’s enabled for the correct module and location.

Also verify that the widget has the correct placement configured. For lead conversion customization, the widget needs to be placed in the ‘Leads Detail Page’ location, not just the module level. The placement settings directly affect when and where the widget’s event handlers are active.

I had this exact issue. The problem is that the EntityAction event listener needs to be registered before the conversion action is initiated. If your widget loads asynchronously, it might not be ready when the user clicks the convert button. Try using a Client Script instead of a widget for this use case - Client Scripts load earlier in the page lifecycle.

Check if your production environment has different security settings than test. Some organizations restrict custom JavaScript execution in production for security reasons. Verify with your Zoho admin that client scripts and widgets are enabled in the production org settings.

In Zoho 2021, the EntityAction event for lead conversion is notoriously unreliable. The event fires at different times depending on whether you’re using the quick convert button or the detailed conversion form. I ended up switching to a different approach using custom buttons instead of relying on the native conversion popup.