This topic is locked
[SOLVED]

 Field Event - Change

6/23/2020 3:05:22 AM
PHPRunner General questions
S
Smithy author

Hello Everyone,
I am trying to retrieve the corresponding employeeid from another table which relates to a card_id. I have had previous success with field events and so I am trying to use them, but every turn I take seems to slam another door shut. Now I can't even get the field event to trigger.

Firstly, I am inputting the card id using an RFID card scanner. It retrieves the card id and adds '\r\n' (CR LF) at the end of the number. It has previously worked without intervention.
On the field called card_id I have attached the following field event:
Client Before:

var ctrlcarduid = Runner.getControl(pageid,'card_uid');

params["carduid_in"] = ctrlcarduid.getValue();



This should retrieve the value of the card I have scanned in the RF card reader from the card_id field..
Server:

$result["employee_id"] = DBLookup("SELECT employee_id FROM card_uid_xref WHERE card_uid = '" . $params['carduid_in'] . "'");



This should set the result "employee_id" to the corresponding employee_id.
Client After:

var ctrlempid = Runner.getControl(pageid,'employee_id');

ctrlempid.setValue(result["employee_id"]);



This should set the employee_id field to the retrieved employee_id, which is the end result I am trying to achieve.
I just cannot get this to work. I have even started a new project from scratch, but to no avail. Should this field event work as I have typed it here ?
I am using this on an apache web server, accessing a MySQL database - list, add and edit pages work fine.
Any help is greatly appreciated.
Best regards,
Craig

Sergey Kornilov admin 6/23/2020

As a first step you need to figure out which part of your code doesn't work, ClientBefore, Server or ClientAfter.
Check for Javascriprt errors first:

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

S
Smithy author 6/23/2020



As a first step you need to figure out which part of your code doesn't work, ClientBefore, Server or ClientAfter.
Check for Javascriprt errors first:

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


Hello Sergey,
Thank you for your sage advice. I followed the documentation, and after a short time found two spelling errors in, and that I was trying to use an invalid method to set a time and date.
Once these were corrected, the code worked.
Sorry for the inconvenience with such a silly error on my part, and thank you for pointing me in the right direction.
Regards,
Craig