Solved

Custom message on delete


Userlevel 3
Badge +5

Our customer wants to indicate which details are depending on the (to be) deleted record.

For instance you have a person with multiple addresses and an address can belong to multiple persons. When deleting an address, they want to have an error message that indicates which persons are still using this address. The user then, first has to remove these connections before it may delete the address.

What's the easiest way to implement this?

icon

Best answer by Mark Jongeling 11 May 2021, 11:33

View original

8 replies

Userlevel 7
Badge +23

Hi Roy,

Using a Task to Delete dependencies + the main record is the most convenient for this. Tasks can also have a confirmation message in which you can use parameters that you can fill with for instance the dependencies.

Alternatively you can use Reference settings like On delete Cascade or On delete Set null but I don't recommend doing this unless you understand the impact it has on your data. Using Tasks does require more maintenance but you do have full control over what happens upon delete.

Userlevel 3
Badge +5

Thanks Mark,

Is it possible to attach this task to the standard delete-action (the red X)?

Userlevel 7
Badge +23

Not yet :wink:  It is on our wish list too:

CRUD tasks | Thinkwise Community (thinkwisesoftware.com)

Userlevel 3
Badge +5

I was afraid of that. But added my vote to this wish.

Hope it will be implemented soon.

Userlevel 3
Badge +5

Extra idea.

Is it possible to use an instead-of-trigger and be able to send an error message from there?

Userlevel 7
Badge +23

You could do that yes if you are using a View. The delete action then triggers that trigger in which an tsf_send_message is executed. It does limit the message to being informational, and not interactable to the extend of letting the user decide to continue or stop the Delete action. This is the main difference with using a Task with a confirmation message.

Userlevel 3
Badge +5

This means that an instead-of-trigger can only work with view (and maybe snapshot), but not with a normal table?

The confirmation message on a task seems like a message with a fixed text. Maybe instead I could use a read-only parameter of which the value will be determined by a default expression. Can I use the t1 or other parameters within this expression?

But probably better to use a task that will start a process flow. There you can first determine which kind of message will be displayed and how to react to that input. And then continue with normal message and delete

Userlevel 7
Badge +23

You can have Instead of triggers on Tables, but it is usually not used as far as I have experienced. About using Snapshots, read the following topic first: What are 'Snapshot' views and how to use them? | Thinkwise Community (thinkwisesoftware.com)

"Can I use the t1 or other parameters within this expression?”:

I believe this won't work as The query cannot use any of the column values of the new recordData model · Thinkwise Docs (thinkwisesoftware.com). I think you will still need to use a Default procedure to fill (hidden/read only) parameters.

Using a Process flow is an option, although it will trigger the message after the Task is successfully executed. So the only way to make this work, if by using a Task without logic first, then give the message and ending with another Task to process the given command; either deleting the records or aborting the Delete entirely.

Reply