Hi Folks,
I am going to hide /show Assign button in Custom entity record based on login user team.
function getUserTeam(executionContext)
{
//debugger;
var isAsyncOperationCompleted = false;
var isButtonEnabled = false;
var formContext = executionContext.getFormContext();
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/teams?$select=name&$filter=teamid eq C8CCF913-8F90-E611-8124-127B25DCBDE7", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function()
{
if (this.readyState === 4)
{
debugger;
req.onreadystatechange = null;
if (this.status === 200)
{
var results = JSON.parse(this.response);
for (var i = 0; i < results.value.length; i++)
{
var Teamname = results.value[i]["name"];
if(Teamname=="EED Supervisor")
{
// Xrm.Utility.alertDialog(Teamname);
isButtonEnabled = true;
}
}
if (isButtonEnabled)
{
formContext.ui.refreshRibbon();
}
}
else
{
isButtonEnabled = false;
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}
Regards
Ajay ch
+91-9113813508