Value from another table to a form

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!

Welcome to DUG and NAV :D
in which fields OnValidate trigger you wrote this code?

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…

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 as

Quote:
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…

It is not completely clear what you want to achieve.

  • What table is your 50016 form is based on?
  • Do you want to just display the “Run Time” from table 99000764 “Routing Line” ? In the table 99000763 “Routing Header” there is no field “Run Time” in standard. Is there is one in your version?
  • Why do you try to insert new records in the routing header and routing line table?
  • The “RecRoutingLine.SETRANGE(RecRoutingLine.“No.”,“Routing No.”);” will not work as you need to go through the “Routing No.” field in the table. The “No.” field refers to either Work Center or Machine Center - depending on the Type field.
  • Why do you utilize the OnValidate trigger as this fires just when a value is entered into that field.

Please clarify.

Hello!

I already got help from another forum, but here’s what I wanted to achieve. I wanted to create a field in a form and I wanted a value from another table to appear in that field as I was filling some fields of that form. And then, in case the imported value was 0, I wanted to run another form to input that value. Here’s the code we came up with, written within the OnInputChange trigger of another field:

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?

in which field you want to store/show the value?

In the TempoExecução field. The same one where I wanted for Run Time values to appear…

Use Fieldname := RecRoutingLine.“Run Time”;

instead of

TempoEx := RecRoutingLine.“Run Time”;

I hope TempoEx is a variable not field

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?

Sorry, i Didnt get your problem…

Where do you need that status?

or you want to set status to Certified for that record?

I already got it. Thanks a lot for your help!