Exclude certain marked data when importing using Dataports.

GumlegufGumleguf Member Posts: 38
Hi,

Newbie question here. :D

We are helping a customer migrating from another ERP system to Dynamics NAV 6. We are able to extract data from the old system into .csv files, which we will then import into NAV 1:1. The client has asked if it would be possible for us to not include data marked with a * infront of the name in the name field - this includes customers, Vendors, Items, etc. It's not something we have recommended them to do, but this has been their way of marking "dead" data for years.

So, have succesfully created the dataport for import, but not sure how I would do the code for excluding data starting with * in the name field. Any hints please?

/G

Comments

  • BeliasBelias Member Posts: 2,998
    Microsoft Dynamics NAV Documentation
    OnAfterImportRecord Trigger
    See Also
    Collapse All Expand All

    Executed after a record has been read from the external (import) file.

    Applies To
    Dataports

    Remarks
    This trigger is only executed when Import Property equals Yes.

    The trigger is executed after the record is read from the table, but before it is inserted into the table. You can use this trigger to perform postprocessing that is required before the record is inserted. You can use the SKIP Function (DATAPORT, REPORT, XMLPORT) to skip inserting this record or stop the processing of the data item by using the BREAK Function (DATAPORT, REPORT, XMLPORT).

    If you add code to this trigger that updates a field, you must ensure that the field has been added to the list of dataport fields. For more information about dataport fields, see Designing Dataports.
    Just check the field value and do a skip in this trigger...by the way...as a best practice, do not use * as an identifier, it is a wildcard, too!!
    Also, try to ask them if they want to maintain these items/customers as blocked items/customers in their new nav database...it would be better, especially if you're going to bring the item ledgers etc. in nav
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • GumlegufGumleguf Member Posts: 38
    Hi Belias,

    Thanks a lot for the explanation.

    I agree with your observation that it is not a good idea to use the * to mark certain data. I will ask the client if it's possible for them to use a different marking.

    I will also take into consideration your suggestion about blocking the customers/vendors/items/etc.

    Just for fun I decided to go ahead and try out your suggestion in a dataport. I'm importing data into table 18 (Customer). The lines I'm importing looks something like this:

    No.;*Companynameexample;Addres 1;Address 2;City;Etc...

    In the dataport I put in the folowing code to see if your suggestions worked (and it did :):

    Customer - OnAfterImportRecord()
    IF Name = '*Companynameexample' THEN
    CurrDataport.SKIP;

    Remaining thing is, that I need to make a filter excluding all customers starting with *, and I'm not sure how to code such a condition. In words it should look like this:

    IF Name begins with * THEN
    CurrDataport.SKIP;

    Anyine has a hint or example for me?

    /G
  • BeliasBelias Member Posts: 2,998
    you should try to search the online help, then ask the senior developer (in other words, your "master"), then search mibuso, then ask mibuso...this will save you time you spend in posting messages here :wink:

    anyway, if you search "search substring" in the online help, you'll find STRPOS function, that fits your needs...
    BTW, you should study some more before implementing such things...be careful and possibly ask a senior developer to give you an hand
    EDIT: you can also use COPYSTR, or even better (this is more advanced)
    if format(name[1]) = '*' then currdataport.skip;
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.