Code Generation for Web API


Found a couple of Syntax issues with the Java Script code generator for the new 2016 Web API.

When doing a Retrieve Multiple, Jquery query, the code generated is this:
var results = data.value;
for (var i = 0; i < results.value.length; i++) {
    var fullname = results.value[i]["fullname"];
It should be:
var results = data.value;
for (var i = 0; i < results.length; i++) {
    var fullname = results[i]["fullname"];
The .value on the results object does not appear to be valid, but if it is removed it works fine.

Second issue I found was with the record creation code. If you select to Create a record with JQuery, you don't set the object and then POST, you have to use a different format.

var entity = {};
entity.primarycontactid = {
            Id: "07C44F4A-8EF9-E411-80F3-1458D04E1AF0",
            LogicalName: "contact"
Should be:
var entity = {};
entity["primarycontactid@odata.bind"] = "/contacts(07C44F4A-8EF9-E411-80F3-1458D04E1AF0)";
Found the other formats for creating records here: http://community.dynamics.com/crm/b/crminogic/archive/2016/02/10/set-values-of-all-data-types-using-web-api-in-dynamics-crm
Closed Oct 19, 2016 at 12:39 AM by JLattimer


JLattimer wrote Oct 19, 2016 at 12:39 AM

These will be fixed in the next version

wrote Oct 19, 2016 at 12:39 AM