Dataports - Importing data

viriatoviriato Member Posts: 105
1. Question
When importing some data into a customer is there another way besides doing it manually for each field to validate the data?

2. Question
If I want to add on record and just fill in the fields that I am importing and fill up all the other fields with defaults values, how would you recommend to do it?

Big Thanks.

Comments

  • matttraxmatttrax Member Posts: 2,309
    1. No, you have to validate each field.

    2. Either do a Customer.INIT in the OnBeforeImportRecord trigger. Or assign values field by field in the OnAfterImportRecord trigger.
  • kinekine Member Posts: 12,562
    ad 1) What does it mean "manually"? You mean "by code"? Do not forget that there is hidden field inthe Dataport Fields form with name "CallFieldValidate" and if you check it, it will validate the field for you... :wink:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • viriatoviriato Member Posts: 105
    Thanks guys. With saying manually I ment by code.
  • kinekine Member Posts: 12,562
    In case of using CallFieldValidate the validation will be in order of the fields, and this can be sometime problem, when the validation is clearing some fields, which were imported before the validated field. It is why I rather use the code than using this way...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,305
    If I need to do anything other than straight importing new records I always like to import into variables and handle field population by C/AL code. Create a variable for each field, and enter them In the dataport fields window. In the OnAfterImportRecord trigger you can then write code to put the values into the database.
  • viriatoviriato Member Posts: 105
    Sounds like importing into variables is the safest way and gives you the best flexibility. Thanks again.
Sign In or Register to comment.