Is this a bug? Please don't tell me this feature was removed? It was incredibly useful.
the onchange event is triggered when the value changes, including when you clear a field.
I am having the same issue as described in the problem description.
This is my code that is on the OnChange event of the field languageid
var page = Xrm.Page;
if (page == null) return;
var obj = page.getAttribute("languageid");
if (obj.getValue() == null)
I think it is caused because this languageid field is required. If I clear it I get a warning that the field is blank, but the OnChange trigger is not fired.
I have the same issue. My script is correct. I created a business rule when the first field not contain data to set the second field with the primary field, in this case, null. but this is not useful, two customizations to do the same thing. it is a bug or the product now works this way?
I have the same issue for a CRM 2013 on-premise environment. I think the issue may be caused by the business requirement of the field.
If the field is business required, removing the value will not trigger onChange event.
Hope this will be fixed by Microsoft CRM team as soon as possible, because this is causing a lot of problems.
Let me know how it goes!
I'm having the same problem.
When the field is 'optional' or 'recommended' the function passed in the 'addOnChange' function will be executed when the field is cleared. But when the field is 'required' and the user clears the field the onchange is not fired.
I think (note: not sure but 'I think') that it has something to do with the new 'field notifications' feature in CRM2013. What this does is put a nice cross in a hexagon when a required field is empty. This happens onChange and probably cancels out the onChange you/I place on the field via JS code.
I also tested it on CRM2011 to be sure (as this does not have the field notification feature) but here all works fine.
Going to search and maybe contact microsoft about it. Keep you posted.
I just encountered this problem as well - my business required field doesn't trigger an OnChange when it's cleared. Please let us know if you get a response from Microsoft!
I am having the same problem. Well, actually it doesn't matter as much in my case. But I would like to know that this behavior will be changed in future or not.
You are right, if the field is required the event dont fire if you are removing the value....horrible.
1. Open a new record
2. Set a value "ABC" to a required field.
3. Move the focus
then, the onchange event is triggered!
4. Remove the value "ABC" from the field.
5. Move the focus.
then, the onchange event is NOT triggered...
But it's still okay becaue I can not save the record anyways because it is a required field.
The real problem comes next.
6. Set a value "ABC" to the field again.
then, the onchange event is NOT triggered!!
(In case, I haven't saved the record yet, I mean, the value "ABC" is definitely a changed value.)
My custom validation code in the onchange event is not fired, which doesn't allow the value "ABC" to be saved. Yes, I could set the validation in the onsave event but I want to show the notification when the value changes.
Step6 makes sense in a weird way.
Because you set the value 'ABC' in the field (@ step 2) the value on that particular moment is 'ABC'. On step 4 you remove the value and the onchange is not triggerd. But at this particular moment the value (in the backend) is still 'ABC' because (for some stupid reason) the backend value is not cleared. I think this is done because the entity will not save due to a required field being empty, and thus it doesn't matter what the backend value is of that field.
So, we arrived at the conclusion that the onchange should be triggered when I remove the value "ABC" at step4. If it is triggered, the onchange of step6 would be triggered too.
I think so yeah. But the problem is that it doesn't and I think Microsoft did this 'by-design'. Because why trigger a onchange (which cost a (tiny) bit of performance) while the user can't save the entity.
Assuming that "ABC" is an invalid value, when I set "ABC" to the required field, the notification "Don't input ABC!!" is displayed by the code I wrote in the onchange event.
And I remove the value "ABC". Then, the notification is removed. (don't know why. I can't handle it anyways) And the notification is never displayed when I set "ABC" to the required field again. In this case, "ABC" could be saved.
I hope this will not be closed with 'by-design'....
Thanks for your reply.
I'm also working (at the moment) with the entire attribute setNotification etc and stumbled against the same problem (like 5 minutes ago).
I don't have a work around for it, but for our situation it is not that big of a deal.
But just like you I hope Microsoft doesn't closes this as a 'by-design'
This issue was solved in Service Pack 1 (support.microsoft.com/.../2941390)
Hope this helps.
Business Applications communities