-----------
Product: Microsoft Dynamics 365 On-Premise
Version: 9.1.43.5
Browser: Chrome (latest)
Entity: Survey (schema name: contact — custom entity)
Subgrid: SurveyGeographicLanguage
Issue Summary
-------------
When a user saves the Survey form, the "Survey Display Languages " subgrid does not display newly created language records (e.g. US-English, US-Spanish) until the page is manually refreshed (F5 or hard refresh).
The data IS being saved correctly to the database — confirmed via Advanced Find. The issue is purely a UI rendering problem where the subgrid does not refresh after save.
This issue does NOT occur in v8.2 where the same code works correctly.
Plugin Details
--------------
Plugin Name: CreateUpdateMultiSelectSurveyOptions
Registration: Post-Operation, Synchronous, Update message
Entity: contact (Survey)
The plugin reads abc_surveygeographicscope JSON field and creates abc_surveygeographicscopelanguage child records after save.
Console Error (Existing Platform Bug)
--------------------------------------
The following error appears in the browser console on every save:
jQuery.Deferred exception: Failed to execute 'evaluate' on
'XPathEvaluator': parameter 2 is not of type 'Node'.
TypeError: parameter 2 is not of type 'Node'.
at Object.SelectSingleNode (global.ashx:6872)
at Mscrm.DataSetObjectInputs.get_$2K_0 (DataSetControl.js:5004)
at Mscrm.DataSetObjectInputs.getParameter (DataSetControl.js:5020)
at Mscrm.DataSetObjectInputs.get_viewId (DataSetControl.js:4987)
at DataSetControl.js:2031
This error originates from CRM internal files (DataSetControl.js and global.ashx) — NOT from custom code. This crash appears to kill the entire save event chain preventing any programmatic subgrid refresh from executing.
Root Cause Analysis
-------------------
1. v8.2 performed full page reload after every save — subgrids automatically re-fetched data on reload.
2. v9.1 introduced Single Page Application (SPA) model — form no longer reloads after save. Subgrids must be explicitly refreshed programmatically.
3. The XPathEvaluator crash in DataSetControl.js blocks all CRM save event APIs from executing correctly in v9.1.43.5.
-----------------
Attempt 1 — subgrid.refresh() in OnSave
Code: Xrm.Page.ui.controls.get("SurveyGeographicLanguage").refresh() Called directly inside existing Survey_OnSave function.
Result: FAILED — XPathEvaluator crash occurs. Fires before plugin creates child records anyway.
Attempt 2 — setTimeout with 1500ms / 5000ms delay
Code: setTimeout(function() { subgrid.refresh(); }, 1500);
Result: FAILED — Race condition. XPathEvaluator crash still occurs regardless of delay duration.
Attempt 3 — formContext.data.addOnPostSave
Code: formContext.data.addOnPostSave(callbackFunction);
Result: FAILED — API not available in v9.1.43.5.
Error: TypeError: formContext.data.addOnPostSave is not a function
Attempt 4 — formContext.data.entity.addOnSave
Code: formContext.data.entity.addOnSave(callbackFunction);
Result: FAILED — Callback registers successfully but never fires.
DataSetControl XPathEvaluator crash kills the save event chain before callback can execute.
Console confirmed: "addOnSave registered" log appears but "callback fired" log never appears.
Attempt 5 — formContext.data.refresh() then subgrid.refresh()
Code: formContext.data.refresh(false).then(function() {
subgrid.refresh();
});
Result: FAILED — Same XPathEvaluator crash blocks execution.
Attempt 6 — Flag Field + addOnChange
Approach: Created new Boolean field abc_subgridrefreshflag on
Survey entity. Modified plugin to toggle this flag after creating child records. JS listens for field change via addOnChange.
Result: FAILED — CRM v9.1.43.5 does not push server-side field updates to the currently open form. addOnChange never fires.
Attempt 7 — addOnSave + Xrm.WebApi Polling
Approach: Used addOnSave to start polling Xrm.WebApi every 1.5 seconds to check if child records exist, then call subgrid.refresh().
Result: FAILED — addOnSave callback never fires due to DataSetControl crash blocking save event chain entirely.

Report
All responses (
Answers (