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!
0
Comments
in which fields OnValidate trigger you wrote this code?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
it would be very helpful to you if you explain with names not as
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
TempoEx is a variable I created just to be the SourceExpr of that field. My intention was to make that value show up...
Onvalidate trigger will be called when user inputs some data in that field
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
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.
and when you have value in "No. Macho"
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
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?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
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?
Try it by placing its onvalidate and by giving the same input again or as u said.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
I think so..
can you copy the code and paste here without screenshot?..in
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Nothing happened...
try adding messages in between the code and check like
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
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.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";
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Beautiful!!!! It worked!!!
What was the difference to the previous code?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
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?
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?
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:
But it doesn't work. Can you help out?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
I have something like this, and it doesn't work:
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav