Create new records with a button
Hello!
I've been learning a lot with Ninox and this forum has been very helpful.
This is the first time that I would be creating a button. But I think it is possible to make the process easier and avoid adding each record individually.
This is for our inventory system. I have a table for all items called "Articulos", I have a table for purchase orders which is called "Ordenes de Compra" and that table has a subtable called "Compras" that has every line item associated with that purchase order.
I also have a table where I add all the vendors information. So the field vendor on both Items and purchase orders tables have the same relationship to the vendors table.
I want to add a button to the purchase order table that when I select a vendor it can add the items that are low in stock and need to be purchased from that specific vendor.
In the Items table the field "Comprar" is the number of items that need to be purchased. So I want to add the Items that have the vendor that I select and that have a "Comprar" value >0
Can you please help me with the code for this button?
13 replies
-
Can you upload a sample DB with sample data?
-
Take a look at the first record in the Ordenes de Compra table.
At the bottom are two new fields, Compras with Proveedores (ComprasProv) and Articulos greater than 0 (Art0).
The record Ids in ComprasProv are from the Compras table where the vendor record Id equals that of the selected field in Proveedor in the Ordenes de Compra table. We have to do this first step because you don't have a direct relationship between proveedor and articulos.
The record Ids in Art0 are related Articulos records from the record Ids returned in ComprasProv that have a Comprar greater than 0.
Please play around with selecting different proveedors and checking that appropriate Articulos show up in Art0.
-
I did a slightly new flow. I created a new Page called Data Entry. There you will see a list of Proveedores. You will see two fields with one that shows all related Articulos and another that shows related Articulos with a Comprar > 0.
If you click on the button it will create a new Ordenes de Compra then create a new record in Compras for each record Id that you saw listed in the field showing records with Comprar > 0. Then it will open up that record up for further editing.
Here is the code:
let t := this; let listofArticulos := Proveedores.Articulos[Comprar > 0]; let newOrdenes := (create 'Ordenes de Compra'); for loop1 in listofArticulos do let newCompras := (create Compras); newCompras.( 'Ordenes de Compra' := newOrdenes; Articulos := loop1 ) end; openRecord(newOrdenes)
-
I also created a button in Ordenes de Compra called add Items and it will add items to the current record you are on.
Content aside
- 1 yr agoLast active
- 13Replies
- 319Views
-
2
Following