Regarding field validation through dataports

gdkve9gdkve9 Member Posts: 161
Hi all,

This post of mine is regarding the validation of required fields in a table while importing data through dataports.
Actually I am importing the purchase order data in to NAV 4.0sp2 from posted invoices of NAV 3.7 version. I am struck at how to find what are all the fields to be validated and the exact order in which the fields are to be validated in a particular table. This is because even if I am adding code for validating some fields like (Location Code, ShortcutDimensionCode1..etc) fields, without those fields getting validated, the data is being inserted in to the purchase header table. So just needed to know whether any way to have an exact order of list of fields to be validated by any manner???? As "CallFieldValidate" doesnt work for me I am validating thru "OnAfterImportRecord" trigger.

And my second doubt is like "Is it necessary that the order in which we specify the dataport fields and the order of the validation that we pose on fields in the "OnAfterImportRecord" trigger need to be same?"

It would be very grateful If I could get some suggestions from U all..
Thanks in advance..
Dilip
Falling down is not a defeat..defeat is when you refuse to get up.

Comments

  • bbrownbbrown Member Posts: 3,268
    If you are using the CallFieldValidate then the order of your dataport fields is important. Since this will determine the order in which they are validated.

    If you are doing you own validation in the OnAfterImport trigger, then the order is less important since you are most likely importing into variables and then using those values to validate the table record fields.

    To determine the order of validation look at the order of entry a user would take. Enter a Purchase Order into the system and note the sequence of fields. Also don't forget any field that are system filled. This is the same sequence your dataport should take. All you are doing with a dataport is automating the process of a user entering the data.
    There are no bugs - only undocumented features.
  • DenSterDenSter Member Posts: 8,305
    I've found the field validation in dataports to be severely inadequate to say the least. Rather than trusting the properties, I would import all field values into variables and then program the validation myself.
  • gdkve9gdkve9 Member Posts: 161
    Thanq Mr.BBrown..

    But I was actually mean to know about any tool or something of kind which gives the exact order of fields to be validated in a particular table. This is because when I am validating the fields according to the User entry in the related form, even then some of the fields are not getting validated (like for example, In the Purchase Header table, even though I am validating the Location Code, ShortcutDimensionCode1 fields etc its not getting validated but other fields like pay-from-vendor, posting Date etc fields are getting validated) but dataport running successfully and data is being inserted in to related table.My concern was on this :-k :-k

    regards to U and all for incoming suggestions.
    Dilip
    Falling down is not a defeat..defeat is when you refuse to get up.
  • Sapphire123Sapphire123 Member Posts: 112
    Hi All,

    I'm trying to attempt something similar...

    I'm importing a list of vendors into the vendor table, and i've written a simple dataport to do this. However, I need to validate some fields in this process, such as Payment Terms & Vendor Posting Groups.

    As per the Help function in NAV, Validate function tests the (1)Table Relation property of the field, and calls the (2)OnValidate trigger. Like DenSter mentioned in pervious post, field validation really doesn't work in dataports. My question is how do I do this in code? I'm not a NAV programmer, but given some guidance, I can try it out :)

    thanks in advance!
  • SavatageSavatage Member Posts: 7,142
    Create Variable for every field you are importing.

    Use these NEW variables as the SourceExpr in the View->Dataport Fields instead of the Nav-direct field.

    This way all your data will be loaded into the variables.
    Then on the OAfterImportRecord Trigger you can map the variables to their Navision counterparts in the order that you want & validate them too.

    example/

    Vendor.No := varVendNo;
    Vendor.Name := varVendName;
    Vendor.Address := varVendAddress;
    etc. etc.

    if you need to validate in there somewhere.

    example/

    Vendor."No." := varVendNo;
    Vendor.Validate("No.");
    Vendor.Name := varVendName;
    Vendor.Address := varVendAddres;
    etc. etc.

    *Quick tip - look at the tables primary key. the fields listed there should all be validated
  • Sapphire123Sapphire123 Member Posts: 112
    Thanks alot... :)

    Validation works for all fields except 'Name' in the Vendor table... :-k

    Here is my code:

    Name := VarName;
    Vendor.VALIDATE(Name);


    I want the above code to update the 'Search Name' field in the Vendor to 'Name'. However, all vendor records ends up with the same search name value, i.e. value from the first record imported.

    e.g.

    Name; Search Name
    V1 ; V1
    V2 ; V1
    V3 ; V1
    ... etc.

    For the time being, I've replaced the following code,

    Name := VarName;
    Vendor.VALIDATE(Name);

    wiht this,

    "Search Name" := VarName;

    ..for it to work.
    Just wondering if this is the way to solve it... :?:
    Thanks again!
  • SavatageSavatage Member Posts: 7,142
    just to be safe
    Name := VarName;
    "Search Name" := UPPERCASE(VarName);
    
Sign In or Register to comment.