This topic is locked

Send Alert from Before record Added

10/2/2023 9:32:43 AM
PHPRunner General questions
author

I am trying to send an alert to the user if the "from" date is greater than the "to" date using this in "Before record added":
if ($values['TravelDate'] > $values['ReturnDate']) { alert("Return date cannot be in the past of travel date. Please revise"); return false; }I get an error regarding "undefined call...". I tried to use swal() but that has the same error too.
Please help

D
david powell 10/2/2023

In asprunner 'before added' is server side / c#.
swal wont work because it isis for client side javascript functions.
You want:
MVCFunctions.EchoToOutput("Your message here");
There is (at least in asprunner) a helpul little icon top of the screen which prepopulates your event with a variety of different functions, sending a message is one.
This one produces a rather unattractive little popup message, but at least it works.....

admin 10/2/2023

There are multiple options to do that but you cannot display a Javascript alert message from a server-side event. It simply doesn't work this way.
If you need to display somethig before the form even submitted, check beforeSave event:
https://xlinesoft.com/phprunner/docs/how_to_ask_for_confirmation_before_saving_record.htm
Another option - use Field Events:
https://xlinesoft.com/phprunner/docs/field_events.htm

502098 10/2/2023

Thank you!! "..ask_for_confirmation_before_saving..." does exactly what I want with one tiny tweak.
Thanks a million