Refresh Form on Subgrid Event -refresh is going into an endless loop

0
48
Role Image


I have a requirement to refresh the form when a sub grid event occurs like add a new record, delete or deactivate a new record.

The refresh is needed because of a calculated/rollup field that needs o be refreshed.

I have an idea using the addOnLoad event of the grid , but the refresh is going on an infinite loop.

My Code is

 

function SubgridEventListener(executionContext)
 {
	let formcontext = executionContext.getFormContext();
	let gridContext = formcontext.getControl("subgridName");
	let gridEvent = function () { formcontext.data.refresh(false);};
	//ensure that the subgrid is ready…if not wait and call this function again
	if (gridContext == null) {
		setTimeout(function () { gridEvent(); }, 15000);
		return;
	}
	//bind the event listener when the subgrid is ready
	gridContext.addOnLoad(gridEvent);
}

Is there any way to implement this with Javascript.



Source link

Leave a reply

Please enter your comment!
Please enter your name here