weird problem when convert the code from navision th SQL

MRQMRQ Member Posts: 73
hi
i have weird problem i wrote some code in navision but when i import
the code in SQL the code dose not work right ](*,)

ok now i well explain the code
the code supose to copy Rec from table Called Ticket and insert this Rec
in the same Table But whit new No. the No. field is the primaryKey

the problem is when i execute the code

this msg appear
do you wont to rename the record

th Code is

Ticket.INIT;
Ticket.COPY(Rec);
Ticket."No.":='';
Ticket."No. Series":='';
Ticket.Confirmed:=FALSE;
Ticket."Conf. Date":=0D;
Ticket.Changed:=FALSE;
Ticket."Change date":=0D;
Ticket.INSERT(TRUE);

and this is the code in the onInsert event
IF "No."='' THEN BEGIN
 TravelSetup.GET;
 TravelSetup.TESTFIELD(TravelSetup."Ticket No. Series" );
 NoSeriesMgt.InitSeries(TravelSetup."Ticket No. Series",xRec."No. Series",0D,"No.","No. Series");
END;
"Date Filter":=WORKDATE;

what is the problem i dont wont this msg To appear #-o [/quote]

Comments

  • krikikriki Member, Moderator Posts: 9,118
    Probably SQL gets confused with the buffers.
    Try this:
    CLEAR(Ticket);
    Ticket.TRANSFERFIELDS(Rec);
    ...
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • MRQMRQ Member Posts: 73
    hi kriki

    sory for late
    CLEAR(Ticket); 
    Ticket.TRANSFERFIELDS(Rec);
    
    i try this but its still give the same Msg.

    i found the problem but i dont know how to fix it
    the problem in the secondary Key for the Tiket Table
    the key is compound of Three Field
    Document Type,Document No.,Line No.

    the Msg apper exactly when insert value in the Document No. field
    i try to empty the field before insert the New Rec
    and the Msg disappeared

    by the way the secondary key fields rrefer to Sales Order
    i use it to Know Each Tiket refer to which Sales Order Line

    so i need to write the Document No in the Rec

    ](*,) ](*,)
    help me Plz
  • krikikriki Member, Moderator Posts: 9,118
    If I understood well, the user is inserting a record in a form and the insert creates another record and then Navision gives the message.
    If I am correct, this happens because in the form you use the secondary key to show records and by inserting a record, the buffers get a little mixed up.
    You might try to put some code in the "OnInsertRecord"-trigger of the form.
    Meaning you save the record "manually", do a refresh of the form, and exit the trigger, saying to Navision to NOT save the record (because you already saved it).
    INSERT(TRUE);
    CurrForm.UPDATE(FALSE);
    EXIT(FALSE);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • MRQMRQ Member Posts: 73
    thank u kriki
    sorry for late

    i solved the problem i just move some function from the table to the form and evry thing is OK \:D/

    thank u again
Sign In or Register to comment.