I want to read two GUIDs in my web-resource to compare them. Both lookup fields have the same related type and an onChange
listener attached.
If I populate the header lookupfield first and the body lookup field second, I get the following result ids:
Xrm.Page.getAttribute("headerLookupField").getValue()[0].id: "91381930-5ae3-e911-812a0050568d4344"
Xrm.Page.getAttribute("bodyLookupField").getValue()[0].id: "{91381930-5AE3-E911-812A-0050568D4344}"
If I do it vice versa, I get both times the correct formatted body id. Now my question:
Why do I get a different GUID format if I populate the header lookup field first?
If it's inconsistent across the system - probably a bug or by design :)
Whenever I'm accessing GUID, this becomes my practice.
Xrm.Page.data.entity.getId().replace("{", "").replace("}", "")
Xrm.Page.getAttribute("lookupfield").getValue()[0].id.replace('{', '').replace('}', '');
On a side note, Xrm.Page
is deprecated in latest version - so time to use the below syntax. Read more
var formContext = executionContext.getFormContext();
var attr = formContext.getAttribute("lookupfield").getValue()[0].id.replace('{', '').replace('}', '');