how to flow data from one table to another?
mdsr
Member Posts: 163
on click of action define on page data from line table go to table newly created table how to achive this.
any help?
code for this ?
any help?
code for this ?
0
Answers
-
Table2Header.INIT;
Table2Header.VALIDATE(Table2Header.Field1,Table1Header.Field1);
Table2Header.INSERT;
0 -
Do you mean that you do not want to validate for each field?
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,0 -
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 codeSend 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;0 -
The filter you're applying to RecProdOrdLine ends up picking only one (last selected) line, that's why it inserts only one line.
You should replace: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.");withCurrPage.SETSELECTIONFILTER(RecProdOrdLine);
This will make sure that the code loops through currently selected (on screen, marked in blue) lines.
Also, your last line in the loopInhousePendingQCList."Serial No.":=InhousePendingQCList."Serial No."+1;
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.0 -
@ShaiHulud i have tried your suggestion but now it gives me following error
Microsoft Dynamics NAV
The Inhouse Pending QC List already exists. Identification fields and values: Serial No.='35'
OK
0 -
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 changeInhousePendingQCList.INSERT;
toInhousePendingQCList.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.
0 -
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 data0 -
Sorry, forgot the "+1" on the insert code, should be
OnInsert() "Serial No." := 1; IF InhousePendingQCList.FINDLAST THEN "Serial No." := InhousePendingQCList."Serial No." + 1;
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
