0
votes

I have one HTML webresource on the custom entity form. There is one lookup on the form called Language with value 'English'. On click of one button in that HTML page, ifsome conditions are not satisfied, I'm setting the Language lookup to null as below code and hiding that lookup.

Xrm.Page.data.entity.attributes.get("new_language").setValue(null);

And again onclick of the same HTML button, if some conditions are satisfied, I'm displaying that Language lookup and the value in that lookup is obviously null as we already set it to null. Then I'll select the value in Language lookup as 'English'.

The issue is, the OnChange event registered on Language lookup field is not triggering and when I access the Language field value from javascript, its showing null. But its trigger the OnChange event and getting lookup value if I select the Language other than 'English'.

Please help me whats wrong in this scenario..

1
add the OnChange code - Guido Preite
But getting null value in Language lookup from Javascript code when English is selected. - Charan Raju C R
but if you don't post your OnChange code, how we can know what it is exactly happening inside the OnChange event? - Guido Preite
On change of the Language it's validating the language is serviceable or not. But its not replacing Language field anywhere in that code. Moreover I'm able to see the selected English language from UI and its working fine when I select any language other than one which we selected before setting it to null. - Charan Raju C R
as you prefer, but did you know that with lookups if you don't set the right record guid the label will be displayed the same but the value is still considered null? If I ask the onchange code is to exclude some possibilities. - Guido Preite

1 Answers

0
votes

Mandatory fields in CRM 2013 don't trigger the OnChange event if emptied. Same if you re-populate the field with the same value.

You need to change to the lookup field value to something else than it previously was to trigger the event.