Tags
clearOptions, crm, CRM 2013, get_editView, Microsoft Dynamics CRM 2013, mscrm, MSCRM 2013, this.get_editView() is null or not an object : Error during jScript Controls.clearOptions() in CRM 2013
Hello Everyone,
This was the third consecutive BUG which I faced in the last few weeks back-to-back. In one of my Previous Blog I discussed about the Dependent PickList / OptionSet solution provided in MSDN which could be very useful and was working fine with my Contacts entity.
I actually wanted to replicate the same functionality within Cases too so that during selection of Customer the Service Representative must be aware of the respective Customer Category and Sub-Category as well. I followed the exact same steps and configured properly the Dependent Picklist Solution. When I first opened the new case then it worked fine as expected.
But after saving the values under Category and Sub-Category when I reopened the case; then it showed an error popping up on the screen saying:-
For a second I thought I might have missed something, so rechecked all the settings but all were configured perfectly as described in MSDN. For a detailed description I opened the same under I.E. and found out a different error screen popping up on the screen:-
Error:- ‘this.get_editView()’ is null or not an object.
I then made up my mind to get deeper into the issue and check for the real cause. I used the debugger and found out that the jScript “Controls[0].clearOption()” was actually throwing the error.
I went more deeper into this and it took me to “this.get_editView().get_editElement().children().remove()”. I Added “this” under the Watch to keep up with the changes.
Next time when I went a step more into this, it was actually trying to return the value under this.$4_0. But the value was actually null, hence was the Error message:- ‘this.get_editView()’ is null or not an object.
Now this ($4_0) came out from nowhere; No idea as what was happening since last couple of weeks between CRM and Me. 😛
I Google out about this Issue and figured out that I was not the only one facing this Issue. The same issue has been discussed over here as well.
Now since my deliverable timeline was very narrow; so I had to find out a way to get this working again. I did some RnD with this for couple of hours and figured out a nice workaround.
Workaround:- Somehow the Child-field control was missing the value under ($4_0) hence I captured the field control once again under a variable and called the clearOptions() method on the freshly captured control. And guess what, It actually worked !!! 😀
Result:- I used the debugger again and found out; this time the value existed for $4_0 on freshly captured Control.
I have logged this Issue under Microsoft Connect. If you are also facing same or came across similar Issue then request to kindly vote for it on the link provided below.
Finally after 3 Months conversation with MS, they have agreed that its a BUG !!!
Now till the time it gets freezes by Microsoft, I guess this workaround will save a lot of time.
Hope this was Helpful.
Thanks !!!
😀
BillV said:
I was having the same issue. I like to drop a bunch of alert()’s into the script when I’m debugging and found that when I had an alert in there prior to the clearOptions() it worked just fine, but as soon as I took it out it would throw the error again. I resolved this by creating a sleep function and pausing execution for 2 seconds before running the clearOptions().
function sleep(miliseconds) {
var currentTime = new Date().getTime();
while (currentTime + miliseconds >= new Date().getTime()) {
}
}
for (var ctrl in controls) {
sleep(2000);
controls[ctrl].setDisabled(false);
controls[ctrl].clearOptions();
…
Ashwani~Ashwin said:
Thanks a lot for sharing.
FLB said:
Thanks a lot, yes, it was helpful.
Resolved my same issue :
/*clearOptions() needs at least one option*/
controls[ctrl].addOption(“generic ChildFieldOption”);
controls[ctrl].clearOptions();
Andrew said:
VERY HELPFUL!!!
Thanks
Ashwani~Ashwin said:
Welcome. M glad it helped.
🙂
Pingback: CRM 2013 - Dependent OptionSets (picklists) error onchange - Microsoft Dynamics CRM Community
Tim Beljavskis said:
Could you type out the code you added to the JScript pictured for your workaround? I have this issue and am trying to edit the SDK.DependentOptionSetSample.js file on my system but it’s a bit hard to read and I am not very good in javascript.
Jonathan Wacks said:
Thanks for this – worked like a charm!