1)Creates a custom button, contains one command (dns.dns_copies.Command.UnCopy)
2)command calling UnCopy javascript (library->$webresource:dns_js/Contact.js) function.
3)command contains 3 parameters
i)[Crm Parameter]=SelectedControl (grid name)
ii)[Crm Parameter]=SelectedControlSelectedItemCount (number of selected rows)
iii)[Crm Parameter]=SelectedControlSelectedItemIds (selected entity ids)
2)command calling UnCopy javascript (library->$webresource:dns_js/Contact.js) function.
3)command contains 3 parameters
i)[Crm Parameter]=SelectedControl (grid name)
ii)[Crm Parameter]=SelectedControlSelectedItemCount (number of selected rows)
iii)[Crm Parameter]=SelectedControlSelectedItemIds (selected entity ids)
/*
Un copy merged contact record.
type - 'f' (from form) or 'g' (from grid)
mergeid - mergeid.
*/
UnCopySingle: function (grid, type, mergeid) {
SDK.REST.retrieveRecord(mergeid, 'dns_copies', 'dns_Converted', null,
function (data) {
if (data != null && !data.dns_Converted) {
var ODataPath = GetCrmUrl() + "/XRMServices/2011/OrganizationData.svc/dns_copiesSet";
$.ajax({
type: "POST",
async: false,
contentType: "application/json; charset=utf-8",
datatype: "json",
url: ODataPath + "(guid'" + mergeid + "')",
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
XMLHttpRequest.setRequestHeader("X-HTTP-Method", "DELETE");
},
success: function (data, textStatus, xhr) {
if (type == 'g') grid.refresh();
else top.window.close();
},
error: function (XmlHttpRequest, textStatus, error) {
CommonOperations.errorHandler(XmlHttpRequest.responseText);
}
});
} else {
var title = "Uncopy";
alert("You cannot uncopy the record. Please contact the HelpDesk for assistance")
}
},
function (error) {
CommonOperations.errorHandler(error);
}
)
},
/*
Un copy merged contact record.
selectedItemCount - no of list item selected
selectedItemIds - list of selected item ids.
*/
UnCopy: function (grid, selectedItemCount, selectedItemIds) {
if (selectedItemCount > 0) {
for (var i = 0; i < selectedItemCount; i++) {
var mergeid = selectedItemIds[i];
RegListAlert.UnCopySingle(grid, 'g', mergeid);
}
}
},
Un copy merged contact record.
type - 'f' (from form) or 'g' (from grid)
mergeid - mergeid.
*/
UnCopySingle: function (grid, type, mergeid) {
SDK.REST.retrieveRecord(mergeid, 'dns_copies', 'dns_Converted', null,
function (data) {
if (data != null && !data.dns_Converted) {
var ODataPath = GetCrmUrl() + "/XRMServices/2011/OrganizationData.svc/dns_copiesSet";
$.ajax({
type: "POST",
async: false,
contentType: "application/json; charset=utf-8",
datatype: "json",
url: ODataPath + "(guid'" + mergeid + "')",
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
XMLHttpRequest.setRequestHeader("X-HTTP-Method", "DELETE");
},
success: function (data, textStatus, xhr) {
if (type == 'g') grid.refresh();
else top.window.close();
},
error: function (XmlHttpRequest, textStatus, error) {
CommonOperations.errorHandler(XmlHttpRequest.responseText);
}
});
} else {
var title = "Uncopy";
alert("You cannot uncopy the record. Please contact the HelpDesk for assistance")
}
},
function (error) {
CommonOperations.errorHandler(error);
}
)
},
/*
Un copy merged contact record.
selectedItemCount - no of list item selected
selectedItemIds - list of selected item ids.
*/
UnCopy: function (grid, selectedItemCount, selectedItemIds) {
if (selectedItemCount > 0) {
for (var i = 0; i < selectedItemCount; i++) {
var mergeid = selectedItemIds[i];
RegListAlert.UnCopySingle(grid, 'g', mergeid);
}
}
},
No comments:
Post a Comment