Hi,
Please see below code to update Business Unit of a Team from JS -
var record = {};
record["businessunitid@odata.bind"] = "/businessunits(80c4ecda-4c5a-ec11-8f8f-002248d4e639)";
var req = new XMLHttpRequest();
req.open("PATCH", Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.2/teams(74b5a34d-fb2f-ec11-b6e6-6045bda5714a)", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=*");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
console.log("Record updated");
} else {
console.log(this.responseText);
}
}
};
req.send(JSON.stringify(record));
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/