record.VALIDATE(field); in a DATAPORT Table 222

imillanimillan Member Posts: 3
Like I can know as they are the fields that I must record.VALIDATE(field); in a table when we are doing in Dataport.

Where I can look at ir?. // pDir.VALIDATE(City); // pDir.VALIDATE("Post Code");

THESE TWO LINES GIVE AN ERROR AND IT IS NOT POSSIBLE TO VALIDATE IT. I HAVE PASSED THE DEBBUGER AND DOES WHAT MUST DO BUT DOES NOT INSERT
pDir.INSERT;


Como puedo saber que campos debo VALIDATE en una tabla, los tipo Code o los que componen la ordenación...????
Corre el report correctamente pero no inserta nada.



Ship-to Address - OnAfterImportRecord()

pDir.RESET;
//pDir.SETCURRENTKEY("Customer No.", Code);
pDir.SETRANGE("Customer No.", "Customer No.");
pDir.SETRANGE(Code, Code);

IF (NOT pDir.FINDFIRST()) THEN BEGIN
pDir.INIT;
pDir."Customer No." := "Customer No.";
pDir.VALIDATE("Customer No.");
pDir.Code := Code;
pDir.VALIDATE(Code);
pDir.Name := Name;
pDir.VALIDATE(Name);
pDir.Address := Address;
pDir.VALIDATE(Address);
IF CP.GET("Post Code", City) THEN BEGIN
pDir.City := CP.City;
// pDir.VALIDATE(City);
pDir."Post Code" := CP.Code;
// pDir.VALIDATE("Post Code");
IF Provincias.GET(CP."County Code") THEN pDir.County := Provincias.Text;
END;
pDir.VALIDATE(County);

pDir.VALIDATE("Name 2");
pDir.VALIDATE("Address 2");
pDir.VALIDATE(Contact);
pDir.VALIDATE("Phone No.");
pDir.VALIDATE("Telex No.");
pDir.VALIDATE("Last Date Modified");
pDir.VALIDATE("Fax No.");
pDir.VALIDATE("Telex Answer Back");
pDir.VALIDATE("E-Mail");
pDir.VALIDATE("Home Page");
pDir.VALIDATE("Tax Area Code");
pDir."Tax Liable" := FALSE;
pDir.VALIDATE("Tax Liable");
pDir.VALIDATE("Shipping Agent Service Code");
pDir.VALIDATE("Service Zone Code");
pDir.VALIDATE("Código metodo transporte");

pDir."Location Code" := '01';
pDir.VALIDATE("Location Code");
pDir.VALIDATE("Shipment Method Code");
pDir.VALIDATE("Shipping Agent Code");
pDir.VALIDATE("Place of Export");
pDir."Country/Region Code" := 'ES';
pDir.VALIDATE("Country/Region Code");

IF pDir.INSERT THEN BEGIN
contador := contador + 1;
END ELSE BEGIN
MESSAGE ('CUIDADO, NO SE ESTAN INSERTANDO LOS REGISTROS!!!!!!!!!!!!!!!');
END;

END;



Ignacio Millán

Comments

  • lvanvugtlvanvugt Member Posts: 774
    Hi Ignacio,

    What are the errors you get? So what text is displayed?

    BTW: ít's not a good practice to just validate all fields. please read my blog post on this.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • matttraxmatttrax Member Posts: 2,309
    There more to dataports than just importing data. You need to understand what to validate and when to do it. Validation occurs because you need to check that a field's value is allowed, or because that field will fill in other fields for you (the no. field on a sales line for example).

    You need to understand the underlying data and code before you write a dataport.
  • SavatageSavatage Member Posts: 7,142
    One suggestions for the future:

    Instead Of mapping the field & then Validating it
    (Your Example)
    pDir.Name := Name;
    pDir.VALIDATE(Name);
    
    IF CP.GET("Post Code", City) THEN BEGIN
    pDir.City := CP.City;
    // pDir.VALIDATE(City);
    

    How about you import all your data into Variables & then Validate all at once.
    p.dir.VALIDATE(Name,varName);
    
    IF CP.GET("Post Code", City) THEN BEGIN pDir.VALIDATE(City,CP.City);
    
    **What's your plan if it doesn't exist?

    & Your Done
    Plus by importing into Variables & mapping them to their proper fields you have more control of where & when you would like stuff to happen.
  • imillanimillan Member Posts: 3
    Thanks lvanvugt, matttrax - There I am learning your blog, very interesting.
    Now I'm looking for and to be intelligent at the time of validating registries.

    I will modify the code before the weekend.

    Savatage - I divide order VALIDATE in two, so that when doing for example

    //pDir.VALIDATE (" code postal");

    it gives an error. Like nonwise where he was decidi to start off and to verify - By this line are separated
    two suppressed lines three to find the error.

    Said this. My question would be, if the code runs correctly, does not give errors, because it does not insert something
    in the table.

    IF pDir.INSERT THEN BEGIN
    contador := contador + 1;
    END ELSE BEGIN
    MENSAJE ('¡ CUIDADO, NO SE ESTAN INSERTANDO LOS CLIENTES!!!!!!!!!!!!!!!');
    END;

    This account passes 2238 registries counted, never I see no message 'CUIDADO'.
    must to execute the INSERT, But does not do it, Reviews with debbuger, sees as it creates the registry in pDir.
    It puts data to data between the commas. The registry is equal to original.

    All is correct, but in line pDir.INSERT; it does not do anything ..... Why?

    1. - The data is correct, Text: = text; decimal: = decimal; etc….
    2. - Validate all the onvalidate of the tables.
    3. - Validate all the onvalidate that can you drag of other objects and relation with tables.

    What must I do so that for inserts data ?.......


    Ship-to Address - OnAfterImportRecord()

    pDir.RESET;
    pDir.SETRANGE("Customer No.", "Customer No.");
    pDir.SETRANGE(Code, Code);

    IF (NOT pDir.FINDFIRST()) THEN BEGIN
    pDir.INIT;
    pDir.VALIDATE("Customer No.", "Customer No.");
    pDir.VALIDATE(Code, Code);
    // pDir.VALIDATE(Name, Name);
    // pDir.VALIDATE(Address, Address);
    // IF CP.GET("Post Code", City) THEN BEGIN
    // pDir.City := CP.City;
    // pDir."Post Code" := CP.Code;
    // IF Provincias.GET(CP."County Code") THEN pDir.VALIDATE(County, Provincias.Text);
    // pDir.County := Provincias.Text;
    // END;
    // pDir.VALIDATE("Location Code", '01');
    // pDir.VALIDATE("Country/Region Code", 'ES');
    // pDir.VALIDATE("Last Date Modified", TODAY);
    // pDir.VALIDATE("Shipment Method Code", 'PPS');
    // pDir.VALIDATE("Shipping Agent Service Code", '');
    // pDir.VALIDATE("Shipping Agent Code", '01');
    // pDir.VALIDATE("Place of Export", 'PPS');
    // pDir.VALIDATE("Tax Liable", FALSE);
    contador := contador + 1;
    pDir.INSERT;
    END;

    this example does not insert anything, exempt either and I put line to prove and INSERT either;

    NO SE QUE HACER.....
Sign In or Register to comment.