Transfer values from one form to another

sarmig
Member Posts: 89
Hello,
I'm faced with another barrier, one that I thought I could break, but I haven't been able to.
Try to follow:
I'm developing a functionality for my company, and it involves two forms (sales line and a custom made form). The goal is to transfer the data from the first form to the second. That I can do. The problem is there is one field in the second form that is not in the first one, and I'm losing my mind trying to filter through tables to get it. Maybe you'll understand better if I post my current code here. This code is in the OnPush trigger of the button I'm using to transfer the fields:
If the filters were all correct, the line RecCarp."No. Equipamento" := RecExtra.Code; should get me the value I was searching, but it isn't happening. I'm asking you to help me once again...
I'm faced with another barrier, one that I thought I could break, but I haven't been able to.
Try to follow:
I'm developing a functionality for my company, and it involves two forms (sales line and a custom made form). The goal is to transfer the data from the first form to the second. That I can do. The problem is there is one field in the second form that is not in the first one, and I'm losing my mind trying to filter through tables to get it. Maybe you'll understand better if I post my current code here. This code is in the OnPush trigger of the button I'm using to transfer the fields:
recSalesLine.INIT; recSalesLine.SETRANGE(recSalesLine.Atribuir, TRUE); IF NOT recSalesLine.FINDFIRST THEN ERROR('Não está qualquer linha seleccionada'); REPEAT RecItem.RESET; RecItem.SETRANGE("No.", "No."); IF RecItem.FINDFIRST THEN BEGIN MESSAGE('%1', RecItem."No."); RecExtra.RESET; //RecExtra.SETRANGE(Tabela, RecExtra.Tabela::LCM); RecExtra.SETRANGE("No. Computador", RecItem."No." + '#'); END; RecCarp.RESET; RecCarp.SETRANGE("Data Registo", TODAY); RecCarp.SETRANGE("Sales No.", recSalesLine."Document No."); RecCarp.SETRANGE("Sales Line No.", recSalesLine."Line No."); RecCarp.SETRANGE("Tipo Operação", "Tipo Operação"::Construção); RecCarp.SETRANGE("No.", recSalesLine."No."); RecCarp.SETRANGE("No. Equipamento", RecExtra.Code); IF RecCarp.FINDFIRST THEN ERROR('O Equipamento encontra-se já em fase de produção da Carpintaria.'); //Rec.INIT; RecCarp."Data Registo":= TODAY; RecCarp."Sales No." := recSalesLine."Document No."; RecCarp."Sales Line No." := recSalesLine."Line No."; RecCarp."No.":=recSalesLine."No."; RecCarp."No. Molde" := recSalesLine."Nº Molde"; RecCarp.Quantity:=recSalesLine.Quantity; RecCarp."Delivery Date":= recSalesLine."Planned Delivery Date"; RecCarp.Estado := Estado::Lançar; RecCarp."Tipo Operação" := "Tipo Operação"::Construção; RecCarp."Sistema Moldação" := recSalesLine."Local de Producao"; IF RecExtra.FINDFIRST THEN RecCarp."No. Equipamento" := RecExtra.Code; RecCarp.INSERT; // MESSAGE('%1', RecCarp."No. Equipamento"); recSalesLine.Atribuir := FALSE; recSalesLine.MODIFY; // recSalesLine.NEXT; UNTIL recSalesLine.NEXT = 0;
If the filters were all correct, the line RecCarp."No. Equipamento" := RecExtra.Code; should get me the value I was searching, but it isn't happening. I'm asking you to help me once again...
0
Comments
-
I didnt check full code but
are you sure you have value in RecExtra.Code?
Put a message after
IF RecExtra.FINDFIRST THEN
Message('%1',RecExtra.Code);
to check whether you got right record or not..
if not check where you are filtering RecExtra..0 -
sarmig wrote:RecExtra.SETRANGE("No. Computador", RecItem."No." + '#');
What does it do?
I never used this kind of code :-k0 -
It adds a '#' to the end of a ref. so that it can be found in that table. the ref.+# represents unfinished products in my company...0
-
If you know how to use Debugger..check the values at run time
or simply put messages and check where the value is missing..0 -
I tried to use the debugger, but the problem is that, in this case, the debugger is not very usable, since every time I try to transfer the values, it runs code in the sales line table (OnModify trigger) and it takes forever to reach the part of the code I want...0
-
I rearranged the code a little bit. Found another way to the values I need without going through the "Extra" table.
recSalesLine.INIT; recSalesLine.SETRANGE(recSalesLine.Atribuir, TRUE); IF NOT recSalesLine.FINDFIRST THEN ERROR('Não está qualquer linha seleccionada'); REPEAT RecItem.RESET; RecItem.SETRANGE("No.", recSalesLine."No." + '#'); IF RecItem.FINDFIRST THEN BEGIN RecCarp.RESET; RecCarp.SETRANGE("Data Registo", TODAY); RecCarp.SETRANGE("Sales No.", recSalesLine."Document No."); RecCarp.SETRANGE("Sales Line No.", recSalesLine."Line No."); RecCarp.SETRANGE("Tipo Operação", "Tipo Operação"::Construção); RecCarp.SETRANGE("No.", recSalesLine."No."); RecCarp.SETRANGE("No. Equipamento", RecItem."Cod Equip"); IF RecCarp.FINDFIRST THEN ERROR('O Equipamento encontra-se já em fase de produção da Carpintaria.'); // Rec.INIT; RecCarp."Data Registo":= TODAY; RecCarp."Sales No." := recSalesLine."Document No."; RecCarp."Sales Line No." := recSalesLine."Line No."; RecCarp."No.":=recSalesLine."No."; RecCarp."No. Molde" := recSalesLine."Nº Molde"; RecCarp.Quantity:=recSalesLine.Quantity; RecCarp."Delivery Date":= recSalesLine."Planned Delivery Date"; RecCarp.Estado := Estado::Lançar; RecCarp."Tipo Operação" := "Tipo Operação"::Construção; RecCarp."Sistema Moldação" := recSalesLine."Local de Producao"; RecCarp."No. Equipamento" := RecItem."Cod Equip"; RecCarp.INSERT; MESSAGE('%1', RecCarp."No. Equipamento"); recSalesLine.Atribuir := FALSE; recSalesLine.MODIFY; END; UNTIL recSalesLine.NEXT = 0;
The thing is, I tried to transfer 7 lines, and only the first 2 had the "No. Equipamento", the rest were empty. What am I missing?0 -
And now I know why...The values didn't exist. This problem's solved!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions