When you set value for Lookup attribute using JavaScript, with Dynamics 365 we have to take care of following issues which were not there in previous versions.
Problem: Problem is if any of the Lookup attribute values are changed before Save then once the Save is completed it will trigger OnChange event of the Lookup attribute.
- When setting id property make sure that GUID is enclosed in curly braces and its all UPPER Cases
- Following code will cause OnChange event getting triggered
var lookupItem = new Object();
lookupItem.id = ‘{6976e322-1d82-e711-80ec-005056b80363}”;
- Following code will cause OnChange event getting triggered
-
- Following code should work without any problem
var lookupItem = new Object();
lookupItem.id ='{6976E322-1D82-E711-80EC-005056B80363}’;
- Following code should work without any problem
- When setting entity logical name you could have used typename earlier without any problem however this property is no more supported and should be replaced by entityType
- Following code must be avoided
var lookupItem = new Object();
lookupItem.typename = ‘new_protochildentity’;
- Following code must be avoided
-
- Following is correct way to set entity logical name
var lookupItem = new Object();
lookupItem.entityType = ‘new_protochildentity’;
- Following is correct way to set entity logical name
- Also name property should also match exactly