{"id":3846,"date":"2020-06-17T05:59:12","date_gmt":"2020-06-17T05:59:12","guid":{"rendered":"https:\/\/himbap.com\/blog\/?p=3846"},"modified":"2020-06-17T06:00:10","modified_gmt":"2020-06-17T06:00:10","slug":"typeerror-cannot-read-property-value-of-null","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=3846","title":{"rendered":"TypeError: Cannot read property &#8216;value&#8217; of null"},"content":{"rendered":"<p><strong>Problem<\/strong><br \/>\nRecently got one issue reported from old code where FetchXML request is executed with XrmServiceToolkit. It was throwing <strong>&#8220;TypeError: Cannot read property &#8216;value&#8217; of null&#8221;<\/strong>.<\/p>\n<p><strong>Solution<\/strong><br \/>\nWe are already in process of upgrading all the old code to new Xrm.WebApi code but this was kind of showstopper as custom html web resource was not loading because of this issue. To solve this issue we removed XrmServiceToolkit and replaced it with new Xrm.WebApi request like below and it started working again.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nasync function ExecuteFetchXML(entityname,fetchxmlreq) {\r\n   \r\n    fetchxmlreq = &quot;?fetchxmlreq=&quot; + encodeURIComponent(fetchxmlreq);\r\n\r\n    \/\/using this request on the html webresource so need to use window.parent before Xrm.WebApi\r\n    await window.parent.Xrm.WebApi.retrieveMultipleRecords(entityname, fetchxmlreq).then(\r\n        function success(response) {\r\n            return response.entities;\r\n        }\r\n         },\r\n        function (error) {\r\n         return null;\r\n        }\r\n    );\r\n\r\n\/\/We can call above method using like following\r\n    var fetchxmlreq=&quot;FetchXRML Query&quot;;\r\n    var FetchXMLResponse = await ExecuteFetchXML(&quot;account&quot;,fetchxmlreq);\r\n<\/pre>\n<p>You can create fetchxmlreq using XrmToolBox fetch xml editor or can use AdvancedFind to design and download it.<\/p>\n<p>Hope it will help someone!<br \/>\n<strong>Keep learning, Keep sharing !!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Recently got one issue reported from old code where FetchXML request is executed with XrmServiceToolkit. It was throwing &#8220;TypeError: Cannot read property &#8216;value&#8217; of null&#8221;. Solution We are already in process of upgrading all the old code to new Xrm.WebApi code but this was kind of showstopper as custom html web resource was not loading because of this issue&#8230;. <a href=\"https:\/\/himbap.com\/blog\/?p=3846\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,402,522],"tags":[777,775,778,479,776],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3846"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3846"}],"version-history":[{"count":5,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3846\/revisions"}],"predecessor-version":[{"id":3851,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3846\/revisions\/3851"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}