Confirming before deleting record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2011 03:44 PM
So i've spent a lot of time researching the wiki for an answer to this and it's probably very simple, but I just can't find it.
I want to have the global delete UI Action load a confirm() to verify the click before SN deletes a record. Problem is that the confirm() is client-side only script and current.deleteRecord(); is a server-side only function.
Is there an easy way to have a confirmation box before running some script that ultimately ends with current.deleteRecord(); ?
Thanks!
Zach S.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2011 12:21 AM
Hi Zach, yes it's possible but you need 2 things, 1 ui action and 1 client script.
The client script will triggered when you click on the ui Action. Is this what you need?
Regards,
Lam
ui action:
Name: Delete record
Action name: delete_record
Global: true
Script: current.deleteRecord();
client script:
Name: Verify Delete record
Type: onSubmit
Table: task
Inherited: true
Script:
function onSubmit() {
if (g_form.getActionName() == 'delete_record')
{
var msg = ("Are you sure you want to permanently remove this record?");
return confirm(msg);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2011 07:28 AM
That's exactly what I was looking for. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2012 06:59 AM
Hi Zach,
Would you mind sharing the scripts that you ended up with?
Thanks
Luciano
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2012 12:51 PM
Here's the code I ended up using.
Client Script
Name: confirm popup
Type: onSubmit
Active: true
Table: Global
Global: checked
Inherited: checked
Script:
function onSubmit() {
var confirmation = false;
var msg;
switch (g_form.getActionName()){
case 'delete_checked': //this is the value of the Action Name for each UI Action
msg = "Are you sure you want to permanently remove this record?"; //The message that pops up in the confirm box.
break;
case 'reshcedule_CHG':
msg = "Are you sure you want to reschedule this change?";
break;
case 'Void':
msg = "Are you sure you want to void this request?";
break;
}
if (msg){return confirm(msg);}}