Stateless from, 'Insert Into' a table only when data in field is not null, using if (input.DATA != null)
I have the code below in a stateless form. The idea of the stateless form is to enter inventory movements. The heading of the form has the data that is common for the inventory transaction (date, Inventory to location, Inventory from location, Number of transacion). And the lower half of the form has multiple lines to enter a product code and quantity. The idea is that the user enters the basic information only once and then fills in all the product codes and quantities necessary. On click, the stateless from should register the inventory movements in a table called Stock_Movimientos. Each record should have the uniform information and 1 product code/quantity combination. I've made the first product code and quantity required fields, and all the rest are not required.
I'm using 'insert into' to pass the records the the table - a new 'insert into' for each product code/quantity combination. It works fine if I fill in all the product code/quantity fields. However when I leave one of these blank, I receive an error. My strategy to solve this was to use an if 'product code' not null statement and execute the insert into only when the relevant product code is not null. However, I receive the following message "Error occured while executing on click script" when I submit the form. To me the code makes sense (but I'm not a programmer).
I would really appreciate it if someone could take a quick look at the code and tell me why it doesn't work. Also, I'm more than open minded about using a different strategy to achieve my goal, being a single form with fields for info in the header common to the transaction, and then multiple lines of fields for entering the detail data, all but the first being optional.
FYI the form is in spanish. Quick translation: fecha1=date, Entra_a=Inventory to location, Sale_de=Inventory from location, Remito_Numero=Number of transacion.
Thanks very much in advance for your help!!!
insert into Stock_Movimientos
[
Added_User = zoho.loginuser
Cantidad = input.Cantidad
Codigo = input.Codigo
Entra_a = input.Entra_a
Fecha = input.Fecha1
Remito_Numero = input.Remito_Number
Sale_de = input.Sale_de
]
if (input.Codigo1 != null)
{
insert into Stock_Movimientos
[
Added_User = zoho.loginuser
Cantidad = input.Cantidad1
Codigo = input.Codigo1
Entra_a = input.Entra_a
Fecha = input.Fecha1
Remito_Numero = input.Remito_Number
Sale_de = input.Sale_de
]
}
openUrl("http://creator.zoho.com/ericweynand/srtapeel/#Form:Remito", "same window");