- Mon Apr 10, 2017 11:50 am
#790221
I have a simple Dynaform with the following 5 text boxes. A table "customer" on MySQL having the first four fields (in same names) is created.
CIN (string, read only, int and auto increment in MySQL)
cust_name (string, varchar in MySQL)
cust_mobile (string, varchar in MySQL)
cust_email (string, varchar in MySQL)
custQuery (string, SQL = SELECT CIN, concat(CIN, "|", cust_name, "|", mobile, "|", email) as custContact from customer where cin = @@CIN)
On Dynaform, I have the following function, so that when user input a valid CIN, the Name, Mobile and Email will be retrieved; and if customer
If I modify the email field and click "next step", no errors and database is updated accordingly.
What have I missed?
CIN (string, read only, int and auto increment in MySQL)
cust_name (string, varchar in MySQL)
cust_mobile (string, varchar in MySQL)
cust_email (string, varchar in MySQL)
custQuery (string, SQL = SELECT CIN, concat(CIN, "|", cust_name, "|", mobile, "|", email) as custContact from customer where cin = @@CIN)
On Dynaform, I have the following function, so that when user input a valid CIN, the Name, Mobile and Email will be retrieved; and if customer
Code: Select all
2. After form triggers are created:
$("#cin").setOnchange(function(){
var aResult = getFieldById("custQuery").executeQuery();
if (Array.isArray(aResult) && aResult.length > 0) {
$aFields = aResult[0].text.split("|");
$("#cin").setValue($aFields[0]);
$("#cust_name").setValue($aFields[1]);
$("#cust_email").setValue($aFields[2]);
$("#cust_mobile").setValue($aFields[3]);
}
})
Code: Select all
It works fine, no problem in creating new customer records, and the lookup by using CIN is working too. Only that if I retrieved a customer record then click "next step" on the form immediately without changing form data it comes back with "Error updating customer"insertNewCustomer (condition = empty(@@CIN))
$db = "812342ba3b7003230y375yyasddsad54";
$cust_name = @@cust_name;
$cust_email = @@cust_email;
$cust_mobile = @@cust_mobile;
$result = executeQuery("INSERT INTO CUSTOMER (cust_name, cust_email, cust_mobile) VALUES ('$cust_name', '$cust_email', '$cust_mobile')", $db) or die ("Error inserting customer");
updateCustomer (condition = !empty(@@CIN))
$db = "812342ba3b7003230y375yyasddsad54";
$cust_name = @@cust_name;
$cust_email = @@cust_email;
$cust_mobile = @@cust_mobile;
$result = executeQuery("UPDATE CUSTOMER SET cust_name = '$cust_name', cust_email = '$cust_email', cust_mobile = '$cust_mobile'", $db)
or die ("Error updating customer");
If I modify the email field and click "next step", no errors and database is updated accordingly.
What have I missed?