DataPort

subrata.baurisubrata.bauri Member Posts: 21
I have a txt file which contains item no and Description .
I want to insert these values into a table (TableA) which contaions Item No1 and Descriptions1.

For this I have created a DATAPORT for TableA.

I want to do this in this away first dataport match the item no with the Item No1. and THEN insert the Descrition into the Description1 ELSE insert nothing?

How it will be controlled?

Comments

  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    There are properties for that. I don't remember the exact name, it's something like AutoUpdate or AutoInsert (just press F1 on each similar looking property). If it's set correct, then it will update those records where the primary key is the same as you imported.

    If that field is not a primary key in this table, then you have to do it by code (SETCURRENTKEY - SETRANGE - FIND('-') the record, VALIDATE the field, MODIFY the record and so on). Probably in the OnAfterImport trigger.
  • prasslprassl Member Posts: 24
    I am not 100% sure, but I think the onafterImport() trigger (of the data item) might be too late to do that.

    When I have to do validation by code in a dataport (e.g. cropping field entries which are too long) I'm using the onBeforeEvaluateField trigger.

    It is passed the parameter Text by reference, where you can modify the field before the data is inserted.
    This is where I would implement the logic to check the import, the same way you suggested it.

    But, as I said, it is just a suggestion that works for me. :)

    cheers, m.
    ... I am not a programmer, I just write code.
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    It's OK when directly importing to fields. For updating data, which is not connected by primary keys, one can import into global variables, and then write the code to update the data in the tables in the OnAfterImport trigger.
  • prasslprassl Member Posts: 24
    ah, I see. :)
    well, of course this was something I didn't understand in the question then - but looking at it again now, I think you re right.

    thanks for clarifying it.
    ... I am not a programmer, I just write code.
Sign In or Register to comment.