The CreatorCon Call for Content is officially open! Get started here.

Confirming before deleting record

zschneider
Kilo Expert

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.

7 REPLIES 7

Lam_Hoang
Kilo Expert

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);
}
}


zschneider
Kilo Expert

That's exactly what I was looking for. Thanks!


Luciodv
Kilo Explorer

Hi Zach,

Would you mind sharing the scripts that you ended up with?

Thanks
Luciano


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);}}