Value from another table to a form

sarmig
Member Posts: 89
Hi there,
I was just hired by a company and I'm supposed to work with Navision. Needless to say I'm a newbie with this software and, therefore, here I am asking for help.
The first thing I was asked to do is to make a value (from the field Run Time) from table 99000763 (I don't know if this is a default table from the software, or if it was created my our tech engineer) on form 50016, on a field I created...
What I did until now was creating the field on the form i want the value to show up and write this code in the OnValidate section of the field I created in the form (some names are in portuguese, never mind that):
RecRoutingHeader.RESET;
RecRoutingHeader.SETRANGE(RecRoutingHeader."No.","No. Macho");
IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN
RecRoutingHeader."No." := "No.";
RecRoutingHeader.Description := Description;
RecRoutingHeader.INSERT;
END;
"Routing No." := "No.";
RecRoutingLine.RESET;
RecRoutingLine.SETRANGE(RecRoutingLine."No.","Routing No.");
IF NOT RecRoutingLine.FINDFIRST THEN BEGIN
RecRoutingLine."No." := "No.";
RecRoutingLine.Description := Description;
RecRoutingLine."Run Time" := "Run Time";
RecRoutingLine.INSERT;
END;
TempoEx := RecRoutingLine."Run Time";
Can you see what I'm trying to do here? We are a factory, I'm trying to import to the form the time it takes to fabricate certain product. That value is already in another table, but I want it to appear in the form as I fill it.
I know its kinda hard to explain the situation, and I appreciate any help you can give to a rookie like me. Even if you can't tell me specifically what I should do, at least give me some pointers. Thanks in advance!
I was just hired by a company and I'm supposed to work with Navision. Needless to say I'm a newbie with this software and, therefore, here I am asking for help.
The first thing I was asked to do is to make a value (from the field Run Time) from table 99000763 (I don't know if this is a default table from the software, or if it was created my our tech engineer) on form 50016, on a field I created...
What I did until now was creating the field on the form i want the value to show up and write this code in the OnValidate section of the field I created in the form (some names are in portuguese, never mind that):
RecRoutingHeader.RESET;
RecRoutingHeader.SETRANGE(RecRoutingHeader."No.","No. Macho");
IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN
RecRoutingHeader."No." := "No.";
RecRoutingHeader.Description := Description;
RecRoutingHeader.INSERT;
END;
"Routing No." := "No.";
RecRoutingLine.RESET;
RecRoutingLine.SETRANGE(RecRoutingLine."No.","Routing No.");
IF NOT RecRoutingLine.FINDFIRST THEN BEGIN
RecRoutingLine."No." := "No.";
RecRoutingLine.Description := Description;
RecRoutingLine."Run Time" := "Run Time";
RecRoutingLine.INSERT;
END;
TempoEx := RecRoutingLine."Run Time";
Can you see what I'm trying to do here? We are a factory, I'm trying to import to the form the time it takes to fabricate certain product. That value is already in another table, but I want it to appear in the form as I fill it.
I know its kinda hard to explain the situation, and I appreciate any help you can give to a rookie like me. Even if you can't tell me specifically what I should do, at least give me some pointers. Thanks in advance!
0
Comments
-
Welcome to Mibuso and NAV
in which fields OnValidate trigger you wrote this code?0 -
I wrote it on the OnValidate trigger of the field I created on the form i want it to show up. I just want a value from another table to show up on the form as I fill it...0
-
You should have written in TempoEx fields onvalidate as you have to show that field..
it would be very helpful to you if you explain with names not asI wrote it on the OnValidate trigger of the field I created on the form i want it to show up. I just want a value from another table to show up on the form as I fill it...0 -
mohana_cse06 wrote:You should have written in TempoEx fields onvalidate as you have to show that field..
it would be very helpful to you if you explain with names not asI wrote it on the OnValidate trigger of the field I created on the form i want it to show up. I just want a value from another table to show up on the form as I fill it...
TempoEx is a variable I created just to be the SourceExpr of that field. My intention was to make that value show up...0 -
Then in which trigger you wrote and what was the result?
Onvalidate trigger will be called when user inputs some data in that field0 -
mohana_cse06 wrote:Then in which trigger you wrote and what was the result?
Onvalidate trigger will be called when user inputs some data in that field
I wrote it on the OnValidate trigger of the TempoEx field (The field is actually called TempoExecução)
I'll be uploading some images:
Img1: I want to fill manually the field Nº OPL and No. Linha OP. Most of the field already fill themselves automatically, and I want the field "Tempo" to be filled too.
Img2: As you can see, on the OnValidate trigger of the TempoExecução field, i have the code.0 -
This code vl be executed when you input value in TempoExecução field
and when you have value in "No. Macho"0 -
mohana_cse06 wrote:This code vl be executed when you input value in TempoExecução field
and when you have value in "No. Macho"
That's the thing. I don't want to input any value on TempoExecução. I want that field to be filled automatically with the value from the field Run Time from table 99000764.
Where should I put the code? Under which trigger?
How do I make the value of that field show up automatically?0 -
Try it in placing Onopen form trigger and OnAftergetrecord trigger.0
-
mohana_cse06 wrote:Try it in placing Onopen form trigger and OnAftergetrecord trigger.
Nothing happened. Is something wrong with the code?
Can I make it in a way that it gets the value after I input No. Linha OP?0 -
Do you have value in "No. Macho"?
Try it by placing its onvalidate and by giving the same input again or as u said.0 -
sarmig wrote:mohana_cse06 wrote:Try it in placing Onopen form trigger and OnAftergetrecord trigger.
Nothing happened. Is something wrong with the code?
I think so..
can you copy the code and paste here without screenshot?..inyour code here
0 -
mohana_cse06 wrote:sarmig wrote:mohana_cse06 wrote:Try it in placing Onopen form trigger and OnAftergetrecord trigger.
Nothing happened. Is something wrong with the code?
I think so..
can you copy the code and paste here without screenshot?..inRecRoutingHeader.RESET; RecRoutingHeader.SETRANGE(RecRoutingHeader."No.","No. Macho"); IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No."; RecRoutingHeader.Description := Description; RecRoutingHeader.INSERT; END; "Routing No." := "No."; RecRoutingLine.RESET; RecRoutingLine.SETRANGE(RecRoutingLine."No.","Routing No."); IF NOT RecRoutingLine.FINDFIRST THEN BEGIN RecRoutingLine."No." := "No."; RecRoutingLine.Description := Description; RecRoutingLine."Run Time" := "Run Time"; RecRoutingLine.INSERT; END; TempoEx := RecRoutingLine."Run Time";
0 -
try this code
RecRoutingHeader.RESET; RecRoutingHeader.SETRANGE("No.","No. Macho"); IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No. Macho"; RecRoutingHeader.Description := Description; RecRoutingHeader.INSERT; END; "Routing No." := "No."; RecRoutingLine.RESET; RecRoutingLine.SETRANGE("Routing No.","Routing No."); IF NOT RecRoutingLine.FINDFIRST THEN BEGIN RecRoutingLine"Routing No." := "Routing No."; RecRoutingLine.Description := Description; RecRoutingLine."Run Time" := "Run Time"; RecRoutingLine.INSERT; END; TempoEx := RecRoutingLine."Run Time";
0 -
mohana_cse06 wrote:try this code
RecRoutingHeader.RESET; RecRoutingHeader.SETRANGE("No.","No. Macho"); IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No. Macho"; RecRoutingHeader.Description := Description; RecRoutingHeader.INSERT; END; "Routing No." := "No."; RecRoutingLine.RESET; RecRoutingLine.SETRANGE("Routing No.","Routing No."); IF NOT RecRoutingLine.FINDFIRST THEN BEGIN RecRoutingLine"Routing No." := "Routing No."; RecRoutingLine.Description := Description; RecRoutingLine."Run Time" := "Run Time"; RecRoutingLine.INSERT; END; TempoEx := RecRoutingLine."Run Time";
Nothing happened...0 -
Where did you add this code?
try adding messages in between the code and check likeRecRoutingHeader.RESET; RecRoutingHeader.SETRANGE("No.","No. Macho"); IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No. Macho"; RecRoutingHeader.Description := Description; RecRoutingHeader.INSERT; END; RecRoutingHeader."Routing No." := "No."; // Modified this line again Message('%1',RecRoutingHeader."Routing No."); RecRoutingLine.RESET; RecRoutingLine.SETRANGE("Routing No.",RecRoutingHeader."Routing No."); // // Modified this line again IF NOT RecRoutingLine.FINDFIRST THEN BEGIN RecRoutingLine"Routing No." := "Routing No."; RecRoutingLine.Description := Description; RecRoutingLine."Run Time" := "Run Time"; RecRoutingLine.INSERT; END; Message('%1',RecRoutingLine."Run Time"); TempoEx := RecRoutingLine."Run Time";
0 -
mohana_cse06 wrote:Where did you add this code?
try adding messages in between the code and check likeRecRoutingHeader.RESET; RecRoutingHeader.SETRANGE("No.","No. Macho"); IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No. Macho"; RecRoutingHeader.Description := Description; RecRoutingHeader.INSERT; END; RecRoutingHeader."Routing No." := "No."; // Modified this line again Message('%1',RecRoutingHeader."Routing No."); RecRoutingLine.RESET; RecRoutingLine.SETRANGE("Routing No.",RecRoutingHeader."Routing No."); // // Modified this line again IF NOT RecRoutingLine.FINDFIRST THEN BEGIN RecRoutingLine"Routing No." := "Routing No."; RecRoutingLine.Description := Description; RecRoutingLine."Run Time" := "Run Time"; RecRoutingLine.INSERT; END; Message('%1',RecRoutingLine."Run Time"); TempoEx := RecRoutingLine."Run Time";
It doesn't compile. Routing No. is not a field of any record variable. Its just a code variable. Do I need it?0 -
sarmig wrote:mohana_cse06 wrote:Where did you add this code?
try adding messages in between the code and check likeRecRoutingHeader.RESET; RecRoutingHeader.SETRANGE("No.","No. Macho"); IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No. Macho"; RecRoutingHeader.Description := Description; RecRoutingHeader.INSERT; END; RecRoutingHeader."Routing No." := "No."; // Modified this line again Message('%1',RecRoutingHeader."Routing No."); RecRoutingLine.RESET; RecRoutingLine.SETRANGE("Routing No.",RecRoutingHeader."Routing No."); // // Modified this line again IF NOT RecRoutingLine.FINDFIRST THEN BEGIN RecRoutingLine"Routing No." := "Routing No."; RecRoutingLine.Description := Description; RecRoutingLine."Run Time" := "Run Time"; RecRoutingLine.INSERT; END; Message('%1',RecRoutingLine."Run Time"); TempoEx := RecRoutingLine."Run Time";
It doesn't compile. Routing No. is not a field of any record variable. Its just a code variable. Do I need it?
My bad! It just does not exist in RecRoutingHeader. It exists in RecRoutingLine. Sorry...0 -
sarmig wrote:sarmig wrote:mohana_cse06 wrote:Where did you add this code?
try adding messages in between the code and check likeRecRoutingHeader.RESET; RecRoutingHeader.SETRANGE("No.","No. Macho"); IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No. Macho"; RecRoutingHeader.Description := Description; RecRoutingHeader.INSERT; END; RecRoutingHeader."Routing No." := "No."; // Modified this line again Message('%1',RecRoutingHeader."Routing No."); RecRoutingLine.RESET; RecRoutingLine.SETRANGE("Routing No.",RecRoutingHeader."Routing No."); // // Modified this line again IF NOT RecRoutingLine.FINDFIRST THEN BEGIN RecRoutingLine"Routing No." := "Routing No."; RecRoutingLine.Description := Description; RecRoutingLine."Run Time" := "Run Time"; RecRoutingLine.INSERT; END; Message('%1',RecRoutingLine."Run Time"); TempoEx := RecRoutingLine."Run Time";
It doesn't compile. Routing No. is not a field of any record variable. Its just a code variable. Do I need it?
My bad! It just does not exist in RecRoutingHeader. It exists in RecRoutingLine. Sorry...
I tried using the code on the No. Linha OP field, OnInputChange trigger. And something happened. The messages appeared. The problem is, the first one came empty and the second one showed a 0. Am I not using the right variable?RecRoutingHeader.RESET; RecRoutingHeader.SETRANGE("No.","No. Macho"); IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No. Macho"; RecRoutingHeader.Description := Description; RecRoutingHeader.INSERT; END; RecRoutingHeader."No." := "No."; // Modified this line again MESSAGE('%1',RecRoutingHeader."No."); RecRoutingLine.RESET; RecRoutingLine.SETRANGE("Routing No.",RecRoutingHeader."No."); // // Modified this line again IF NOT RecRoutingLine.FINDFIRST THEN BEGIN RecRoutingLine."Routing No." := "Routing No."; RecRoutingLine.Description := Description; RecRoutingLine."Run Time" := "Run Time"; RecRoutingLine.INSERT; END; MESSAGE('%1',RecRoutingLine."Run Time"); TempoEx := RecRoutingLine."Run Time";
0 -
RecRoutingHeader.RESET;
RecRoutingHeader.SETRANGE("No.","No. Macho");
IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN
RecRoutingHeader."No." := "No. Macho";
RecRoutingHeader.Description := Description;
RecRoutingHeader.INSERT;
END;
Message('%1',RecRoutingHeader."No.");
RecRoutingLine.RESET;
RecRoutingLine.SETRANGE("Routing No.",RecRoutingHeader."No."); // // Modified this line again
IF NOT RecRoutingLine.FINDFIRST THEN BEGIN
RecRoutingLine"Routing No." := RecRoutingHeader."No.";
RecRoutingLine.Description := Description;
RecRoutingLine."Run Time" := "Run Time";
RecRoutingLine.INSERT;
END;
Message('%1',RecRoutingLine."Run Time");
TempoEx := RecRoutingLine."Run Time";0 -
mohana_cse06 wrote:RecRoutingHeader.RESET;
RecRoutingHeader.SETRANGE("No.","No. Macho");
IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN
RecRoutingHeader."No." := "No. Macho";
RecRoutingHeader.Description := Description;
RecRoutingHeader.INSERT;
END;
Message('%1',RecRoutingHeader."No.");
RecRoutingLine.RESET;
RecRoutingLine.SETRANGE("Routing No.",RecRoutingHeader."No."); // // Modified this line again
IF NOT RecRoutingLine.FINDFIRST THEN BEGIN
RecRoutingLine"Routing No." := RecRoutingHeader."No.";
RecRoutingLine.Description := Description;
RecRoutingLine."Run Time" := "Run Time";
RecRoutingLine.INSERT;
END;
Message('%1',RecRoutingLine."Run Time");
TempoEx := RecRoutingLine."Run Time";
Beautiful!!!! It worked!!!
What was the difference to the previous code?0 -
Replaced RecRoutingHeader."Routing No." with RecRoutingHeader."No."0
-
Anyway, great. Thanks a lot.
Just one more thing. I need to create a mechanism that, in case Run Time = 0, the form where I can input that data opens automatically.
From where should I start?0 -
I think I got it. Here's the code I came up with:
RecRoutingHeader.RESET; RecRoutingHeader.SETRANGE("No.","No. Macho"); IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No. Macho"; RecRoutingHeader.Description := Description; RecRoutingHeader.INSERT; END; //MESSAGE('%1',RecRoutingHeader."No."); RecRoutingLine.RESET; RecRoutingLine.SETRANGE("Routing No.",RecRoutingHeader."No."); // // Modified this line again IF NOT RecRoutingLine.FINDFIRST THEN BEGIN RecRoutingLine."Routing No." := RecRoutingHeader."No."; RecRoutingLine.Description := Description; RecRoutingLine."Run Time" := "Run Time"; RecRoutingLine.INSERT; END; //MESSAGE('%1',RecRoutingLine."Run Time"); TempoEx := RecRoutingLine."Run Time"; IF RecRoutingLine."Run Time" <= 0 THEN IF CONFIRM ('Queres dar um tempo?') THEN FORM.RUN(99000766, RecRoutingHeader, RecRoutingHeader."No.");
But now I have another problem. The code works, and as I'm filling the form, the value of Run Time automatically shows up in the TempoExecução field. But then, when I scroll down to the next line, and then back to the first, that value becomes 0. Its like it doesn't store the value. Is there a field property I should change or is it really a code problem?0 -
I got it to work. Thanks. Now, for the next problem:
My RecRoutingHeader table has an option type variable called "Status".
I need that everytime I add a value to Run Time, The Status variable instantly becomes certified. I tried a few solutions, like:RecRoutingHeader.Status := RecRoutingHeader.Status::Certified;
But it doesn't work. Can you help out?0 -
You want to set Status to certified in My RecRoutingHeader or you want to access that and show in present form?0
-
I want to set the status in RecRoutingHeader to Certified...0
-
It wont modify in RecRoutingHeader until you use
RecRoutingHeader.MODIFY;
After your code0 -
mohana_cse06 wrote:It wont modify in RecRoutingHeader until you use
RecRoutingHeader.MODIFY;
After your code
I have something like this, and it doesn't work:IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN RecRoutingHeader."No." := "No. Macho"; RecRoutingHeader.Description := Description; RecRoutingHeader.Status := RecRoutingHeader.Status::Certified; RecRoutingHeader.INSERT; END ELSE BEGIN RecRoutingHeader.Status := RecRoutingHeader.Status::Certified; RecRoutingHeader.MODIFY; END;
0 -
check with debugger or with messages..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