Unable to update Customer Card (Salesperson code field)

nikeman77
nikeman77 Member Posts: 517
i have a dataport that takes in 3 field:

1.customer code,
2.old salesperson code,
3.new salesperson code

Its suppose to functions as find the customer code, replace the new salesperson from csv file.

-My csv files have 2 record for testing purposes, all data
(customer code, old salesperson code, new salesperson code )in the csv files are valid data

-My Data Field for dataport as follows:
CustCode
OldSMCode
NewSMCode

-Properties

AutoSave = <YES>
AutoUpdate = YES
AutoReplace=<No>


Without using the commit code at the end of my code, it can't modified the necessary records.

Cust.Modify;
COMMIT;


Answers

  • nikeman77
    nikeman77 Member Posts: 517
    my salesperson code i tried both using validation and direct assignment but it doesnt works
    cust."salesperson code" := NewSMCode;
    cust.VALIDATE("salesperson code",NewSMCode);
    PS: There isnt any coding inside Customer table, salesperson code.VALIDATE
  • nikeman77
    nikeman77 Member Posts: 517
    it seems like import & excel management cannot co-exists.
  • colingbradley
    colingbradley Member Posts: 162
    I presume that the 3 fields are all variables?

    Set DataItem as Integer (NOT Customer)
    SORTING(Number)
    AutoSave, update,Replace = No
    Dataport properties:
    Import = Yes

    Integer - OnAfterImportRecord()
    CLEAR(RecordVar);
    RecordVar.SETRANGE("No.",Var1);
    IF RecordVar.FINDSET THEN WITH RecordVar DO
    REPEAT
    "Yourfield Code" := Var2;
    MODIFY;
    UNTIL RecordVar.NEXT=0;

    Your code would be more like:
    IF Cust.GET(Var1) THEN BEGIN
    Cust.."Yourfield Code" := Var2;
    etc...
    Cust.MODIFY;
    END;

    The data could be saved from Excel as TAB delimited and you set up the delimiters in the dataport to match
    <TAB> in place of the <,> if the comma is used in the data (not in this case however).

    Cheers,
    Colin
    Experience is what you get when you hoped to get money