This project is read-only.
1
Vote

Soap BusinessEntity Deserialize Issue for EntityRefernce in Dynamics CRM 2016

description

deserializing an EntityRefernce attribute is broken in Dynamics CRM2016 Online. The Attribute node has 2 additional child nodes and the first three do not match how they were returned in CRM 2015.

I am referring to line 1772 and following lines:
                                case "a:EntityReference":
                                    entRef = new xrmEntityReference();
                                    entRef.type = sType.replace('a:', '');
                                    var oChildNodes = tempNode.childNodes;
                                    entRef.id = getNodeText(oChildNodes[0]);
                                    entRef.logicalName = getNodeText(oChildNodes[1]);
                                    entRef.name = getNodeText(oChildNodes[2]);
                                    obj[sKey] = entRef;
                                    break;
oChildNodes[0] still happens to be the id, but the other two have moved. For this to continue to work, the nodename must be interpreted before assigning a value. I.e. we need something like this:
                                case "a:EntityReference":
                                    entRef = new xrmEntityReference();
                                    entRef.type = sType.replace('a:', '');
                                    var oChildNodes = tempNode.childNodes;
                                    for (var n = 0; n < oChildNodes.length; n++) {
                                      var currentNodeName = oChildNodes[n].nodeName;
                                      switch (currentNodeName) {
                                        case "a:Id":
                                          entRef.id = getNodeText(oChildNodes[n]);
                                          break;
                                        case "a:Name":
                                          entRef.name = getNodeText(oChildNodes[n]);
                                          break;
                                        case "a:LogicalName":
                                          entRef.logicalName = getNodeText(oChildNodes[n]);
                                          break;
                                      }
                                    }
                                    obj[sKey] = entRef;
                                    break;

comments