admin管理员组文章数量:1313615
I have a scenario where in Orders Form there is a Invoice Schedule Sub-grid. I need to Refresh/Reload the Main Form when the Invoice Schedule Sub-grid is reloaded on Deactivating a particular record in the Sub-grid.
P.S: This scenario is for Dynamics 365 CRM Unified Interface (UCI). I have tried all the three Sub-grid events but does not help in this scenario.
I have a scenario where in Orders Form there is a Invoice Schedule Sub-grid. I need to Refresh/Reload the Main Form when the Invoice Schedule Sub-grid is reloaded on Deactivating a particular record in the Sub-grid.
P.S: This scenario is for Dynamics 365 CRM Unified Interface (UCI). I have tried all the three Sub-grid events but does not help in this scenario.
Share Improve this question edited Jan 27, 2020 at 19:53 Arun Vinoth PrecogTechnologies 22.8k17 gold badges62 silver badges177 bronze badges asked Jan 27, 2020 at 11:02 Ronak LodayaRonak Lodaya 1311 gold badge6 silver badges15 bronze badges4 Answers
Reset to default 3You have to attach a custom event handler to deal this. Read more
var globalFormContext;
function myFormOnload(executionContext) {
globalFormContext = executionContext.getFormContext();
addSubgridEventListener();
}
function addSubgridEventListener(){
var gridContext = globalFormContext.getControl("<your_subgrid_name>");
//ensure that the subgrid is ready…if not wait and call this function again
if (gridContext == null){
setTimeout(function () { addSubgridEventListener(); }, 500);
return;
}
//bind the event listener when the subgrid is ready
gridContext.addOnLoad(subgridEventListener);
}
function subgridEventListener(context){
globalFormContext.data.refresh(false);
}
For UCI: From ribbon button pass the parameter of PrimaryControl and use below code to Refresh.
PrimaryControl.refresh();
This latest code verified and works in v9 unified interface Reference: https://learn.microsoft./en-us/powerapps/developer/model-driven-apps/clientapi/reference/grids/gridcontrol/addonload
Code snippet:
//On load of main form event
function OnloadOfMainForm(executionContext) {
// call onLoad of subgrid function
SubgridEventHandler(executionContext);
}
var globalFormContext;
function SubgridEventHandler(executionContext){
//make formContext as global
globalFormContext = executionContext.getFormContext();
var gridContext = globalFormContext.getControl("subgrid_name");
//Verify the subgrid is loaded, if not recursively call function again
if (gridContext != null && gridContext != undefined){
//don't try to pass formEontext some time it doesn't works
gridContext.addOnLoad(SubgridFunctionExe);
}else{
setTimeout(function () { SubgridEventHandler(); }, 200);
}
}
//It triggers onLoad of form, on load and on refresh of subgrid
//as well on add new record and on delete of record it will trigger
function SubgridFunctionExe(){
// here use globalFormContext
globalFormContext.data.refresh(false);
}
To be honest, the best solution in my case is this simple code (an example for the entity contact):
var lookupOptions = {};
lookupOptions.entityType = "contact";
Xrm.Utility.refreshParentGrid(lookupOptions);
This works both on the form, subgrid etc. My issue was that if you call formContext.data or formContext.ui, you get undefined if the UCI Refresh button was hit on a view or a grid (not from the form). With the code above, you don't need formContext. Read more here: https://debajmecrm./refresh-homepage-grid-and-ribbon-on-click-of-custom-button-button-in-dynamics-365-refresh-selective-entity-charts-and-grids-on-dynamics-365-dashboard-yes-it-is-possible-using-xrm-utility-refreshpare/
版权声明:本文标题:javascript - Reload Form on reloadrefresh of subgrid in Dynamics 365 CRM Unified Interface - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741921765a2405043.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论