Dear all.
Microsoft Dynamics 365. Version 1612 (9.0.8.9).
I am facing a problem with customising a subgrid, adding an event handler OnLoad.
I add an OnLoad event handler to the subgrid.
The addition occurs when the form is loaded on the OnLoad event of the form, using the technique described in the documentation.
docs.microsoft.com/.../addonload
The handler is added successfully and works. But after adding the OnLoad handler, the presence of the "Plus button" on the subgrid becomes unstable.
In other words: it is impossible to predict the presence of the "Plus Button" on the subgrid, with each new loading of the form, if the OnLoad handler for the grid is added.
Sample code:
OnLoad: function (executionContext) { var formContext = executionContext.getFormContext(); // get the form context var gridContext = formContext.getControl("Contacts");// get the grid context var myContactsGridOnloadFunction = function () { console.log("Contacts Subgrid OnLoad event occurred") }; gridContext.addOnLoad(myContactsGridOnloadFunction); }
SubGrid Image:
Please help..
Thanks.
Hello.
If there is no other solution, I will use this approach.
Thank you so much for your help.
Hi,
Inaccuracy, which you mentioned, I don't think has much effect on the results. The former is a delay for the first step and the latter is a delay for all steps.
In terms of conclusion, my code is able to solve the problem of the button not being displayed on the version I am using and the value 3000 means that the timer is only 3 seconds long and is not felt very directly. Please try to see if this solves your problem, as no more suitable solution has been found so far.
If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.
Best Regards,
Nya
Thanks for the reply. But I would like to do without a timer. In addition, there is an inaccuracy in your code. I think it should be like this:
function formonLoad(executionContext){ setTimeout(function(){ console.log("Hello"); var formContext = executionContext.getFormContext(); // get the form context var gridContext = formContext.getControl("Contacts"); var myContactsGridOnloadFunction = function () { console.log("Contacts Subgrid OnLoad event occurred") }; gridContext.addOnLoad(myContactsGridOnloadFunction); }, 3000); }
Hi,
I can reproduce your issue with Version 1612 (9.0.2.3034) and I found that several other users have given feedback on similar issues.
e.g. Add new button disappeared from subgrid - Microsoft Dynamics CRM Forum Community Forum
According to my tests, it should be that the JS takes effect before these buttons are loaded. The buttons can be shown after refreshing the page. So I added a setTimeOut in the function.
Here is my code.
function formonLoad(executionContext){
setTimeout(function(){ console.log("Hello"); }, 3000);
var formContext = executionContext.getFormContext(); // get the form context
var gridContext = formContext.getControl("Contacts");
var myContactsGridOnloadFunction = function () {
console.log("Contacts Subgrid OnLoad event occurred")
};
gridContext.addOnLoad(myContactsGridOnloadFunction);
}
Add it into the main form of Account and set it as the following image.
After adding the setTimeOut, the add button can be shown when the page is loaded for the first time.
Please have a try to figure out if it will solve your problem.
If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.
Best Regards,
Nya
Siv Sagar
149
Super User 2025 Season 1
Muhammad Shahzad Sh...
61
Most Valuable Professional
Daivat Vartak (v-9d...
53
Super User 2025 Season 1