An alternate approach to Confirm Delete functionality

By | June 24, 2011

CRM follows a nice procedure of soft deletion of records for all the tables to maintain the consistency of the data. It also has a confirm delete functionality wherein when any user deletes any entity record he is redirected to new screen with Confirm Delete button. When we design custom entity through wizard, we get the delete button, but no confirmation is asked after clicking it. What if user clicks it by mistake and accidentally deletes the record? Below is the procedure that you can follow to implement simple Confirm Delete functionality on your custom pages.

1. Put the Delete button on your asp page as per standard way.

2. Call client side JavaScript function on your delete button as shown below.

Container.AddButton(eWare.Button (“Delete”,”delete.gif”, javascript: fn_Delete ();”));

3. Inside the JavaScript function put the confirmation box to take confirmation from user before deletion. Refer below script.

Script

< script language=javascript >
//’Function for handle the delete button
function fn_Delete()
{
//’For confirmation
var sconfirm = confirm(“Are you sure you want to delete this entry?”)

//’if it gets true then deletes the record
if(sconfirm)
{
//This is the standard mark up of delete button but will execute only afterconfirmation
x=location.href;
i=x.search(‘&em=’);
if (i >= 0)
{
x=x.substr(0,i)+x.substr(i+2+3,x.length);
}
x=x+’&’+’em’+’=’+’3′;
location.href=x
}
}
< /script >

If you find this content useful, please drop us an email at crm@greytrix.com.