This topic is locked

Help with Field Event

11/11/2019 3:34:20 PM
PHPRunner General questions
M
Melanie authorDevClub member

Hoping someone can help with a field event. I have the code working, but I want to check if we get a result and if not I want the event to stop and tell the user and then they can edit again. I have
Client before:

params["value"] = this.getValue();


Server:

$sql = "Select oid from location_master where

location_id = '".$params["value"]."'";

$rs = CustomQuery($sql);

$data=db_fetch_array($rs);

$result["locoid"]=$data["oid"];

$result["SQL"] = $sql;

$result["upper"] = strtoupper( $params["value"] );


Client After:

var ctrlLoc = Runner.getControl(pageid,'Location_oid');

this.setValue( result["upper"] );


If the sql returns nothing I want to prompt the user - they did not enter a valid location and stay in the field for them to enter again.

Sergey Kornilov admin 11/18/2019

The basic idea is to check if SQL query returned something and pass something like 'okay' or 'notokay' from Server to ClientAfter event.
In this article (example 1) we show how you can display a message next to the Edit control:

https://xlinesoft.com/phprunner/docs/field_events.htm
Also here is an example of how to check if specific record exists:

https://xlinesoft.com/phprunner/docs/check_if_specific_record_exists.htm