Trigger on create with numeric fields
I am creating a table from another table with trigger on create with this code.
let a := Factura.Cliente.Cliente;
let b := Empresa;
let c := Monto
let d := Fecha
let p := (create Flujo);
p.('Cliente / Proveedor' := a);
p.(Empresa := b);
p.(Concepto := "Ingresos");
p.('Monto Prov' := c);
p.(Fecha := d)
It works for all text fields but not for numeric fields like date and amount.
Please help.
17 replies
-
Just to verify that Monto and 'Monto Prov' are actual number fields and Fecha in both tables are date fields.
-
There are a couple of missing semi-colons in your code
let c := Monto
let d := Fecharegards John
-
Can you post a sample DB?
-
This is my original table
It has the following trigger
I get the following result
What am I doing wrong?
-
Sure.
Thank you very much for your help.
-
Hi,
I think the issue arises because you have put your code inside the 'Trigger on new record'.
Ninox runs your code instantly when you create a new record on the Table Facturado before you have the time to enter any values on the new record fields.
-
I suggest to put your code inside the 'Triger after update'.
-
Hi
Can I suggest that original code
let a := Fecha; let b := Cliente; let c := 'Linea'; let d := Monto; let p := (create 'Flujo de Caja'); p.('Fencha Flujo' := a); p.('Concepto Flujo' := "Ingresos"); p.('Cliente Flujo' := b); p.('Linea Flujo' := c); p.('Monto Flujo' := d)
can move from saving each field as a variable to saving the record as a variable and referencing the fields from this, and also not saving the new record to a variable.
let a := this; (create 'Flujo de Caja').( 'Fencha Flujo' := a.Fecha; 'Concepto Flujo' := "Ingresos"; 'Cliente Flujo' := a.Cliente; 'Linea Flujo' := a.'Linea'; 'Monto Flujo' := a.Monto )
This, though, doesn't help with your original query. If you are putting this in a Trigger after update you might want to check that all the fields are filled in before any new records are created. If not you could end up with a new record for every field that you fill in.
Regards John
-
thanks but it doesn't work either
-
Hi,
The reason I want to do this is that I have several tables with different structures, for example, my billing table has a "customer" field, while my payment table has a "supplier" field. I also have a bank transfer table and others. I want to make a report of all the movements of the month, whether income, expenses or transfers, ordered by the date of the movement.
That is why I thought of creating a table that indicates all the movements, filter them by month and order them by date.
If you have a better way to do it please help me.Thank you very much for your help.
-
Hi,
I've already solved it by taking only the reference number and calculating all the remaining fields.
Thank you very much for your help and advice.
Content aside
- Status Answered
- 1 mth agoLast active
- 17Replies
- 82Views
-
4
Following