How to copy value on Dataport Import

selece28
selece28 Member Posts: 316
Hi All,
I have a question about Dataport,
How to copy value from one fields to another before import using Dataport
Ex: I have two fields, A and B
First both of the Fields is Empty
On Import using Dataport, i only insert into field A, but before insert, i want to copy the value from field A into field B (i want to use field B to keep previous value of field A)

I use code : A:= B; on before Import but the value is incorrect
How to solve this problem

Thanks in advance
______________

Regards,
Steven

Answers

  • lubost
    lubost Member Posts: 633
    The right place is OnAfterImportRecord
  • selece28
    selece28 Member Posts: 316
    No if i put it OnAfterImportRecord, then field B value will be the same as the field A value
    ______________

    Regards,
    Steven
  • lubost
    lubost Member Posts: 633
    ... and what are your dataport fields?
  • selece28
    selece28 Member Posts: 316
    I have 3 fields to import from csv
    lets say fields X,Y,A
    when i import i want to copy field A value to field B, the insert the csv value into X,Y,A

    i also insert a Date type field to keep the update date(workdate)
    ______________

    Regards,
    Steven
  • lubost
    lubost Member Posts: 633
    As I wote before, the right place to fill fields not filled by dataport fields is OnAfterImportRecord trigger. If your field is allready filled, there must be some code to do it (for example in OnValidate trigger in table).
  • Savatage
    Savatage Member Posts: 7,142
    re-read your post. You want to transfer A value to B but you say they both fields are originally blank
    Ex: I have two fields, A and B
    First both of the Fields is Empty
    On Import using Dataport, i only insert into field A, but before insert, i want to copy the value from field A into field B (i want to use field B to keep previous value of field A)

    so B should be blank

    are you saying that on the second line import you want A to retain it's value from the import of the first line?

    now if you can add more detail to your post it would be easier to help you.
  • selece28
    selece28 Member Posts: 316
    Ok here's the example (X is the primary key)

    First my table is like this
    example:
    Column X Y A B D(type = Date)
    Value(Blank all)

    Then i Import csv to fill falue X,Y,A
    example:
    Column X, Y, A, B, D(type = Date)
    Value 1, 1, 1, (blank because copy from A), 27/02/07(workdate)

    Then if i import the next csv to update/insert data
    example:
    Column X, Y, A, B, D(type = Date)
    Value 1, 1, 2, 1(copy from previous value), 27/02/07
    Value 2, 3, 3, (blank), 27/02/07
    Value 3, 4, 4, (blank), 27/02/07

    and so on
    So when import, first i copy value A to B, then insert new imported value to A
    ______________

    Regards,
    Steven
  • lubost
    lubost Member Posts: 633
    It seems that you are importing the file with the same primary key. So, can you send me your object and your csv files, I will try to find the problem.
  • Albertvh
    Albertvh Member Posts: 516
    It seems to me that you should do the following

    Set a global variable MyRecVar type record the same as the dataitem
    you are importing

    in the AfterImportRecord section
    B := '';
    IF MyRecVar.GET(X) THEN
    B := MyRecVar.A;

    Hope this helps
  • selece28
    selece28 Member Posts: 316
    yes, all i want to do is copy the A value to B value before insert a new value into A
    ______________

    Regards,
    Steven
  • selece28
    selece28 Member Posts: 316
    Could anyone helps ](*,)
    ______________

    Regards,
    Steven
  • ssi
    ssi Member Posts: 39
    In OnBeforeImportRecord trigger (first line):
    SaveA := A;
    

    In OnAfterImportRecord trigger:
    B := SaveA;
    

    SaveA is a global variable with same type as A and B.
  • selece28
    selece28 Member Posts: 316
    Thanks but i think my problem solved
    Thank you to Lubost =D> [/code]
    ______________

    Regards,
    Steven
  • selece28
    selece28 Member Posts: 316
    Thanks but i think my problem solved
    Thank you to Lubost =D>


    Upps sorry double post #-o
    ______________

    Regards,
    Steven