Programming conditions in import dataport

ArchyArchy Member Posts: 70
edited 2006-11-03 in Navision Attain
Hi all!

I have an Excel document with fields I have to import to Navision table. Actually in Excel document there are item numbers, item translation and language code. I have to import this document to table Item Translation.

But there is one problem I cannot deal with - some items has already their translations and I should not overwrite them! Furthemore, if an item has translation and the language code in Excel is the same as in item's translation in Navision - I should skipe dataport, but if Excel's translation for this item has different language code - i have to add it.

So, it seems, I have to programm some conditions in the dataport's OnBeforeImportRecord trigger. But how can I use current dataport's field for comparison with database table's field? :-s May be any other ideas? Please, help!!!

Comments

  • David_CoxDavid_Cox Member Posts: 509
    Simple use a variable and

    OnBeforeImportRecord()
    INIT;

    OnAfterImportRecord()
    IF ItemTranslation.GET("Item No.","Language Code")THEN
    CURRDATAPORT.SKIP;
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • krikikriki Member, Moderator Posts: 9,115
    David Cox wrote:
    Simple use a variable and

    OnBeforeImportRecord()
    INIT;

    OnAfterImportRecord()
    IF ItemTranslation.GET("Item No.","Language Code")THEN
    CURRDATAPORT.SKIP;
    IF ItemTranslation.GET("Item No.","Language Code")THEN
    
    should be:
    IF ItemTranslation.GET("Item No.",'',"Language Code")THEN
    
    The primary key is "Item No.","Variant Code","Language Code".
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • SavatageSavatage Member Posts: 7,142
    & don't forget about the

    AutoSave
    AutoUpdate
    AutoReplace

    Properties
  • David_CoxDavid_Cox Member Posts: 509
    kriki wrote:
    David Cox wrote:
    Simple use a variable and

    OnBeforeImportRecord()
    INIT;

    OnAfterImportRecord()
    IF ItemTranslation.GET("Item No.","Language Code")THEN
    CURRDATAPORT.SKIP;
    IF ItemTranslation.GET("Item No.","Language Code")THEN
    
    should be:
    IF ItemTranslation.GET("Item No.",'',"Language Code")THEN
    
    The primary key is "Item No.","Variant Code","Language Code".

    Oh Right I didn't check the primary key, and it's not a table I have used much, on the develoment side !

    Thanks 8)
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • ArchyArchy Member Posts: 70
    David Cox wrote:
    Simple use a variable and

    OnBeforeImportRecord()
    INIT;

    OnAfterImportRecord()
    IF ItemTranslation.GET("Item No.","Language Code")THEN
    CURRDATAPORT.SKIP;


    I'm sorry, I don't understand. :oops: What variable? What type should be this variable? How can I get for comparison value of current record Language Code in Excel?
  • krikikriki Member, Moderator Posts: 9,115
    Archy wrote:
    David Cox wrote:
    Simple use a variable and

    OnBeforeImportRecord()
    INIT;

    OnAfterImportRecord()
    IF ItemTranslation.GET("Item No.","Language Code")THEN
    CURRDATAPORT.SKIP;


    I'm sorry, I don't understand. :oops: What variable? What type should be this variable? How can I get for comparison value of current record Language Code in Excel?
    A global record variable "ItemTranslation" on table "Item Translation".
    The fields "Item No.","Language Code" are filled in by the dataport. These you use to do a GET on "ItemTranslation". If the GET returns a TRUE, it means the record exists, and you can skip it.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ArchyArchy Member Posts: 70
    Oh, I understood, what variable - of type Item Translation. :oops: ok... Then we assume, that imported from Excel language code values are in field "Item Translation"."Language Code"? (I have one data item in this dataport - it is Item Translation)
    But this fields allways are empty! :( I was looking in debugger..
  • krikikriki Member, Moderator Posts: 9,115
    Archy wrote:
    Oh, I understood, what variable - of type Item Translation. :oops: ok... Then we assume, that imported from Excel language code values are in field "Item Translation"."Language Code"? (I have one data item in this dataport - it is Item Translation)
    But this fields allways are empty! :( I was looking in debugger..
    They are filled in between triggering the OnBeforeImportRecord()-trigger and the OnAfterImportRecord()-trigger.

    BTW: did you fill in the fields in the dataport-fields (View=>Dataportfields)?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ArchyArchy Member Posts: 70
    Oops.. :oops: There my mistake was.. Thanks for help! It seems, soon I will get these records. :)
Sign In or Register to comment.