I am trying to intercept a technical error message for a foreign key violation that is happening when a user tries to delete a parent record that still has child records associated with it.
Of course, this is the correct behavior.
My issue is that I want to intercept this message and change it from technical gibberish (from the end user’s perspective) to some more user friendly.
I thought I was being clever when I found the “Message_Showing” event on the Delete Page and put my more friendly end user message under the elseif branch for ‘failure’.
However, when the Delete confirmation page loaded it displayed the message. To me the message should not display until the user actually clicks on the “Delete” button.
You should check the original message in Message_Showing event and change it to your user-friendly message only if the specific message is present (not always set the failure message).
If I uncomment the failure message, save the project, go to the list page, click on Delete it takes me to the delete page and displays “your failure message”. At this point I have not attempted to actually delete the record.
So if I understand you correctly I should add another “if” statement w/n this structure and check for the failure message that talks about the FK violation and if that one gets a hit then populate the $msg variable otherwise do nothing. Is that correct?
I can certainly do that, but it seems…clumsy to me.
So if I understand you correctly I should add another “if”
statement w/n this structure and check for the failure message that talks
about the FK violation and if that one gets a hit then populate the $msg
variable otherwise do nothing. Is that correct?