@wolfskin thanks for information actually i want transfer data from prod order line table to my newly created table.which have different fields name with same datatype what is code in that case.
i want to insert prod.order line table data with selected multiple item should inseert in my created table but only one item inserted though multiple item select on action of released prod. order
here is code
Send To QC - OnAction()
RecProdOrdLine.RESET;
//RecProdOrdLine.SETRANGE(RecProdOrdLine.Status,RecProdOrdLine.Status::Released);
RecProdOrdLine.SETRANGE("Prod. Order No.","Prod. Order No.");
RecProdOrdLine.SETRANGE("Item No.","Item No.");
RecProdOrdLine.SETRANGE("Line No.","Line No.");
IF RecProdOrdLine.FINDSET THEN
REPEAT
BEGIN
InhousePendingQCList.INIT;
InhousePendingQCList."Production Order No.":=RecProdOrdLine."Prod. Order No.";
InhousePendingQCList."Item No.":=RecProdOrdLine."Item No.";
InhousePendingQCList.Location:=RecProdOrdLine."Location Code";
InhousePendingQCList."Total Quantity":=RecProdOrdLine.Quantity;
InhousePendingQCList."QC Quantity":=RecProdOrdLine."QC Quantity";
InhousePendingQCList.INSERT;
// MESSAGE(InhousePendingQCList."Production Order No.");
InhousePendingQCList."Serial No.":=InhousePendingQCList."Serial No."+1;
END;
UNTIL RecProdOrdLine.NEXT=0;
seems a bit disconnected from everything else - there's no setting of initial value of field "Serial No.", so it will always end up being InitValue (field property) + 1. And it comes AFTER your INSERT, so it will not be saved on the record.
That's what the last part of my message was about. "Serial No." is your primary key field, so you need to resolve that somehow by making sure it always has a unique value. If it's just a running number, then you could write a code like this on the OnInsert() trigger on the InhousePendingQCList table:
OnInsert()
"Serial No." := 1;
IF InhousePendingQCList.FINDLAST THEN
"Serial No." := InhousePendingQCList."Serial No." + 1;
where InhousePendingQCList is a variable of type Record and subtype of the table name/No.
Then on the code we talked about earlier you need to change
InhousePendingQCList.INSERT;
to
InhousePendingQCList.INSERT(TRUE);
This will trigger the above written code.
However, two things to consider:
If the Serial No. really works like that, always incrementing by 1, you may consider renaming it to something more appropriate, like "Entry No."
If the Serial No. represents something different than just running number, then you might want to write different logic to handle that.
still getting same error as previous
added code in on insert of table also note that table is having only one key serial no. which is auto increment after adding data
Answers
Table2Header.VALIDATE(Table2Header.Field1,Table1Header.Field1);
Table2Header.INSERT;
If structure of Table1 and Table2 are similar, you can use the TRANSFERFIELDS function to flow all matching fields in one record to another record.
<<https://docs.microsoft.com/en-us/dynamics-nav/transferfields-function--record->>
You can see the example from Table 36 (Sales Header) and Table 112 (Sales Invoice Header).
Sorry if I misunderstand.
Thanks,
I think you know how to assign value on field to another table. So, what is your problem?
here is code
You should replace: with
This will make sure that the code loops through currently selected (on screen, marked in blue) lines.
Also, your last line in the loop seems a bit disconnected from everything else - there's no setting of initial value of field "Serial No.", so it will always end up being InitValue (field property) + 1. And it comes AFTER your INSERT, so it will not be saved on the record.
Microsoft Dynamics NAV
The Inhouse Pending QC List already exists. Identification fields and values: Serial No.='35'
OK
Then on the code we talked about earlier you need to change to This will trigger the above written code.
However, two things to consider:
added code in on insert of table also note that table is having only one key serial no. which is auto increment after adding data