My code is as follows:
var parameters = {};
parameters.DateFrom = JSON.stringify(new Date("03/10/2015 01:30:00").toISOString());
parameters.DateTo = JSON.stringify(new Date("02/13/2050 01:30:00").toISOString());
var product = {};
product.productid = "05f18edb-881a-ea11-a811-000d3ab8d5b5"; //Delete if creating new record
product["@odata.type"] = "Microsoft.Dynamics.CRM.product";
parameters.Product = product;
parameters.Quantity = 5;
var ambcust_CheckProductAvailabilityRequest = {
DateFrom: parameters.DateFrom,
DateTo: parameters.DateTo,
Product: parameters.Product,
Quantity: parameters.Quantity,
getMetadata: function() {
return {
boundParameter: null,
parameterTypes: {
"DateFrom": {
"typeName": "Edm.DateTimeOffset",
"structuralProperty": 1
},
"DateTo": {
"typeName": "Edm.DateTimeOffset",
"structuralProperty": 1
},
"Product": {
"typeName": "mscrm.product",
"structuralProperty": 5
},
"Quantity": {
"typeName": "Edm.Int32",
"structuralProperty": 1
}
},
operationType: 0,
operationName: "ambcust_CheckProductAvailability"
};
}
};
Xrm.WebApi.online.execute(ambcust_CheckProductAvailabilityRequest).then(
function success(result) {
if (result.ok) {
var results = JSON.parse(result.responseText);
}
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
I did this with the REST Builder and made it fromn the ground too so I din't know that to do. the action should return an Output result "IsFree" which is a boolean. It works with the deprecated XMLHttp Request.