0

Variable Scope / Empty fields

Hi

I am using this code in a "Save" button to avoid empty fields in a record:

let MyError := 0;

if Nombre = null then
dialog("Attention", " ""Nombre"" puedes estar vacío", ["OK"]);

let MyError := 1
void
end;
if Email = null then
dialog("Atención", " ""Email"" no puede estar vacío", ["OK"]);

let MyError := 1
void
end;
alert(text(MyError));
if MyError = 0 then
closeRecord()

else void
end;

The idea is if to use MyError as a flag. If any of the conditions is met (Email empty or Name empty) then MyError changes to 1

But when I test MyError via alert(text(MyError)); it always outputs 0 or whatever value I put in the initial definition (let MyError := ). So it is not working.

Any hint on this?

Thanks.

Jaime

PD. Actually I wrote the code below and did work but I want to shorten it:

if Nombre = null then
dialog("Attention", " ""Nombre"" puedes estar vacío", ["OK"]);
void
end;
if Apellido = null then
dialog("Attention", " ""Apellido"" puedes estar vacío", ["OK"]);
void
end;
if Email = null then
dialog("Atención", " ""Email"" no puede estar vacío", ["OK"]);
void
end;
if 'País' = null then
dialog("Atención", " ""País"" no puede estar vacío", ["OK"]);
void
end;
if 'Provincia / Departamento' = null then
dialog("Atención", " ""Provincia / Departamento"" no puede estar vacío", ["OK"]);
void
end;
if Ciudad = null then
dialog("Atención", " ""Ciudad"" no puede estar vacío", ["OK"]);
void
end;
if Nombre != null and Email != null and Apellido != null and 'País' != null and 'Provincia / Departamento' != null and Ciudad != null then
closeRecord()
end

Reply

null

Content aside

  • 5 yrs agoLast active
  • 855Views