Asagıdakı kodu cogunlukla butonları bellı takımlara sahıp kısılerın gormesı durumunda kullanırız.
var result;
function TakimlariGetirGokhan() {
var formType = Xrm.Page.ui.getFormType();
var userid = Xrm.Page.context.getUserId();
result = false;
if (formType == 1) {
var url = Xrm.Page.context.prependOrgName("/xrmservices/2011/OrganizationData.svc/");
var entity = "TeamMembershipSet";
var oDataSelect;
jQuery.support.cors = true;
oDataSelect = url + entity + "?$filter=SystemUserId eq guid'" + userid + "'";
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: oDataSelect,
async: false,
beforeSend: function (XMLHttpRequest) {
//Specifying this header ensures that the results will be returned as JSON.
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
var teamMemberShipEntity = data.d;
if (teamMemberShipEntity.results.length != 0) {
for (var i = 0; i < teamMemberShipEntity.results.length; i++) {
if (teamMemberShipEntity.results[i] != null) {
var _teamid = teamMemberShipEntity.results[i].TeamId;
entity = "TeamSet";
oDataSelect = url + entity + "?$filter=TeamId eq guid'" + _teamid + "'";
jQuery.support.cors = true;
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: oDataSelect,
async: false,
beforeSend: function (XMLHttpRequest) {
//Specifying this header ensures that the results will be returned as JSON.
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
var teamEntity = data.d;
if (teamEntity.results != null && teamEntity.results.length == 1) {
if ((teamEntity.results[0].Name.toUpperCase() == "ACCOUNTS")) {
result =true;
}
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus + "; ErrorThrown: " + errorThrown);
}
});
}
}
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus + "; ErrorThrown: " + errorThrown);
}
});
}
return result;
} // JScript source code
Hiç yorum yok:
Yorum Gönder