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:
- Your widget loads on the Leads detail page
- User clicks ‘Convert Lead’
- Zoho opens the conversion popup in a modal/iframe
- Your EntityAction listener is on the parent page, not in the popup context
- 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:
- Create a workflow that triggers on Lead Status = ‘Converted’
- Use custom functions to populate the required fields on the newly created Account/Contact/Deal records
- 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:
- Open browser DevTools and go to Console tab
- Manually execute: `ZOHO.embeddedApp.emit(‘test’, {data: ‘test’})
- If this fails, the Widget SDK isn’t properly initialized
- Check Network tab for failed widget resource loads
- 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.