I am try this and also get the error.
function OnChangeTeamPrivillage(executionContext) {
debugger;
var formContext = executionContext.getFormContext();
// Getting the value of Case Owner
var Team = formContext.getAttribute("emp_team").getValue();
// Getting the GUID of the lookup record
var Teamid = Team[0].id;
// NOTE: Associate Request in Xrm.WebApi supports multiple children, you can add them inside the relatedEntities array
var associateRequest = {
target: { entityType: "team", id: Teamid },
relatedEntities: [
{ entityType: "role", id: "9ce12383-6a39-4252-9a02-e44b378bba15" }
],
relationship: "teamroles_association",
getMetadata: function () { return { boundParameter: null, parameterTypes: {}, operationType: 2, operationName: "Associate" }; }
};
Xrm.WebApi.online.execute(associateRequest).then(
function success(response) {
if (response.ok) {
console.log("Success");
alert("Success...");
}
}
).catch(function (error) {
console.log(error.message);
alert(error.message);
});
}