Page 1 of 1

Extract a value from a table at the time of capture

Posted: Tue Jun 13, 2017 7:55 am
by eayvl

I need to extract a value from a table, at the time of capture, example:

Table1
idbuscar / TABULADOR / MENSUAL / DIARIO
1 / NORMAL / 2,400.00 / 80.00
1 / NORMAL / 4,500.00 / 100.00
2 / ESPECIAL / 2,400.00 / 120.00
2 / ESPECIAL / 4,500.00 / 200.00

I have 4 fields on my capture page: tabulador, mensual, diario.

In field "tabulador" i have a combobox selection ( NORMAL, ESPECIAL )
in field "mensual" when the salary is entered, I need to search the table1
In field "diario" is the result.

For Example: If I select "NORMAL" and i capture, "3,000.00" the result must appear in field "diario" with "80.00".

I do not know how to do it, but I think the code has to be in:

// Page Loading event
function Page_Loading() {
//echo "Page Loading";
}
// Get a field value
// NOTE: Modify your SQL here, replace the table name, field name and the condition
$MyField = ew_ExecuteScalar("SELECT MyField FROM MyTable WHERE XXX");

Thanks in advance.


Re: Extract a value from a table, at the time of capture

Posted: Tue Jun 13, 2017 11:53 am
by mobhar

It seems you may simply use "Dynamic Selection List" and "Auto fill" features.

Please read "Tutorial - Dynamic Selection List" and "Lookup Table" topic -> "Auto fill" for more info and example.


Re: Extract a value from a table, at the time of capture

Posted: Thu Jun 15, 2017 12:51 pm
by eayvl

Thanks, but It's not what I'm looking for.

What I'm looking for is something like, demo project settings in orderdetails between unitePrice, Quantity and SubTotal.

For Example: If I select in a combobox "NORMAL" and i capture in a field, "3,000.00" find the quantity in a table and the result must appear in field "diario" with "80.00"

In Excel with vlookup I solve it but here I do not know how.

Table1
idbuscar / TABULADOR / MENSUAL / DIARIO
1 / NORMAL / 2,400.00 / 80.00
1 / NORMAL / 4,500.00 / 100.00
2 / ESPECIAL / 2,400.00 / 120.00
2 / ESPECIAL / 4,500.00 / 200.00


Re: Extract a value from a table at the time of capture

Posted: Fri Jun 16, 2017 10:06 am
by arbei

Read the help file topic: "Project Setup" -> "Lookup Table" -> "Ajax by Server Events and Client Scripts" -> "Auto-Fill asynchronously" and see is it what you are looking for.


Re: Extract a value from a table at the time of capture

Posted: Mon Jun 19, 2017 11:23 pm
by eayvl

What I'm looking for may be in the demo project (orderdetails, ProductID field), but with a small change.

For this example, add a field in the table "products" with the name "SALARY" and change in (details of the order, ProductID, Display field # 1 of ProductName change it SALARY) In the field "SALARY" enter values of 100 , 200, 300, 400, etc.

The change I need is:
Add the value of 250 in the field "Product ID". This value searches the "product" table in the "SALARY" field if this value does not exist, extract the value of the nearest quantity and leave the value in Unit Price.

I was reading, read the help file topic: "Project Setup" -> " Lookup Table"
I will surely have to add this code in Server Events, but how are changes made?

$val = json_encode(ew_ExecuteRow("SELECT * FROM products WHERE ProductID = " . $_POST["value"])); // Get the desired value


Re: Extract a value from a table at the time of capture

Posted: Fri Jun 23, 2017 3:15 pm
by arbei

You can follow the example 2 in the help file (see my previous post), and update the SQL that retrieving the UnitPice to Salary and re-write the WHERE Clause.

$val = ew_ExecuteScalar("SELECT Salary FROM <Table> WHERE <Your code to retriving the nearest salary result>);

If you want to discuss, try you hand at it and post your COMPLETE code for discussion.