Deleted Selected multiple Row from Releated list using custom button
Create a Custom button as a List Type Button and Execute JavaScript Code
{!REQUIRESCRIPT('/soap/ajax/29.0/connection.js')}
try
{
var selectedRecords = {!GETRECORDIDS( $ObjectType.QuoteLineItem )};
if(selectedRecords.length < 1)
alert('Please Select at Least One Row !');
else
{
userConsent = confirm(selectedRecords.length + ' Record(s) will be Deleted. Continue ? ');
if(userConsent == true)
{
delResult = sforce.connection.deleteIds(selectedRecords);
var message = '';
var msgFailedReason = '<br/><h3>Failed Record(s)</h3><br/><div style="height: 300px;overflow-y: scroll;"><table style="border-collapse: collapse;">';
var passCount = 0, failCount = 0;
for(var i=0; i < delResult.length; i++){
if(delResult[i].getBoolean('success')){
passCount++;
}
else{
failCount++;
msgFailedReason += '<tr><td style="vertical-align: top; border-bottom: 1px solid gray;">' + delResult[i].errors.message + '</td></tr>';
}
}
msgFailedReason += '</table></div>';
message =
'<b>Record(s) Submitted</b> : ' + selectedRecords.length + '<br/>' +
'<b>Record(s) Deleted</b> : ' + passCount + '<br/>' +
'<b>Failed Record(s)</b> : ' + failCount + '<br/>';
if(failCount > 0)
message += msgFailedReason;
message += '<p align="center"><button class="btn" onclick="window.parent.resultWnd.hide(); window.parent.location.reload(); return false;">Close</button></p>';
var resultWnd = new SimpleDialog("Mass-Delete-QL-" + Dialogs.getNextId(), false);
resultWnd.setTitle("Status - Mass Delete Quote Line Items");
resultWnd.createDialog();
window.parent.resultWnd = resultWnd;
resultWnd.setContentInnerHTML(message);
resultWnd.show();
}
}
}
catch(e)
{
alert('The Action Could not be Completed. Error Message: ' + e);
}
Snaps
{!REQUIRESCRIPT('/soap/ajax/29.0/connection.js')}
try
{
var selectedRecords = {!GETRECORDIDS( $ObjectType.QuoteLineItem )};
if(selectedRecords.length < 1)
alert('Please Select at Least One Row !');
else
{
userConsent = confirm(selectedRecords.length + ' Record(s) will be Deleted. Continue ? ');
if(userConsent == true)
{
delResult = sforce.connection.deleteIds(selectedRecords);
var message = '';
var msgFailedReason = '<br/><h3>Failed Record(s)</h3><br/><div style="height: 300px;overflow-y: scroll;"><table style="border-collapse: collapse;">';
var passCount = 0, failCount = 0;
for(var i=0; i < delResult.length; i++){
if(delResult[i].getBoolean('success')){
passCount++;
}
else{
failCount++;
msgFailedReason += '<tr><td style="vertical-align: top; border-bottom: 1px solid gray;">' + delResult[i].errors.message + '</td></tr>';
}
}
msgFailedReason += '</table></div>';
message =
'<b>Record(s) Submitted</b> : ' + selectedRecords.length + '<br/>' +
'<b>Record(s) Deleted</b> : ' + passCount + '<br/>' +
'<b>Failed Record(s)</b> : ' + failCount + '<br/>';
if(failCount > 0)
message += msgFailedReason;
message += '<p align="center"><button class="btn" onclick="window.parent.resultWnd.hide(); window.parent.location.reload(); return false;">Close</button></p>';
var resultWnd = new SimpleDialog("Mass-Delete-QL-" + Dialogs.getNextId(), false);
resultWnd.setTitle("Status - Mass Delete Quote Line Items");
resultWnd.createDialog();
window.parent.resultWnd = resultWnd;
resultWnd.setContentInnerHTML(message);
resultWnd.show();
}
}
}
catch(e)
{
alert('The Action Could not be Completed. Error Message: ' + e);
}
Snaps
Thanks
Sumit Shukla
sumitshukla.mca@gmail.com
Comments
Post a Comment