Hello Everyone,
Through the use of the 8.0 WEB API and JavaScript, I am trying to create a product on the Sales Order that is open at the time.
Attempting to create even the most simplistic of products under the Sales Order is resulting in an error message.
Here is a link to a CRUD Library of the new WEB API that I am using due to its similarity with the SDK.REST library for previous versions of CRM.
http://www.zacrmguy.com/js-crud-operations-with-web-api-in-crm-2016/
Here is a snippet of the basic code that I am using in my web resource:
var thisOrderId = Xrm.Page.data.entity.getId(); thisOrderId = thisOrderId.replace("{", "").replace("}", ""); var newProduct = new Object(); newProduct["salesorderid@odata.bind"] = "/salesorders(" + thisOrderId + ")"; newProduct["priceperunit"] = 35.0000; newProduct["quantity"] = 1.0000;
SDK.WEBAPI.createRecord(newProduct, "salesorderdetails", function () { }, function (error) { alert(error.message);}, function () { });
I have also tried this without the priceperunit or the quantity what I am receiving what appears to be the same error message:
Developer tools shows a response of error code 500 with the following in the response body: "Error in CreateOrderDetail."
Would anyone happen to know if there is a required field that I am missing for a SalesOrderDetail or know what might be going on with this?
I appreciate any and all advice.
Thanks so much!
*This post is locked for comments