Code in Dataport

What are you validating it with, though? Is it already filled in with data?

Usually it is something like RecRoutingLine.VALIDATE(“No.”, The Value to Store in the No. Field);

Also, you can press F2, F2, Enter to revalidate the field on a form.

But can I press those buttons through code?

I tried RecRoutingLine.VALIDATE(“No.”, RecRoutingLine.“No.”);

and it didn’t work…

So, still no ideas for my problem?!

Meanwhile, I tried another solution. The description which should show up automatically is stored in the Machine Center table. I did something like this:

RecMachineCenter.RESET;
RecMachineCenter.SETRANGE(“No.”, RecRoutingLine.“Routing No.”);
RecRoutingLine.Description := RecMachineCenter.“No.”;
RecRoutingLine.MODIFY;

But it also didn’t work…

Where did u write this code?

RecMachineCenter.RESET;
RecMachineCenter.SETRANGE(“No.”, RecRoutingLine.“Routing No.”);

IF RecMachineCenter.FINDFIRST THEN;

RecRoutingLine.Description := RecMachineCenter.Name;
RecRoutingLine.MODIFY;

What if Type is Work Center?

I made a mistake, sorry. I’m still half asleep :stuck_out_tongue:

The code is now like this:

RecRoutingHeader.RESET;
RecRoutingHeader.SETRANGE(“No.”,RecItem.“No.”);

IF NOT RecRoutingHeader.FINDFIRST THEN BEGIN
RecRoutingHeader.“No.” := RecItem.“No.”;
RecRoutingHeader.Description := RecItem.Description;
RecRoutingHeader.Status := RecRoutingHeader.Status::Certified;
RecRoutingHeader.INSERT;
END;

RecRoutingLine.RESET;
RecRoutingLine.SETRANGE(“Routing No.”, RecItem.“No.”);

IF NOT RecRoutingLine.FINDFIRST THEN BEGIN
RecRoutingLine.“Routing No.” := RecItem.“No.”;
RecRoutingLine.“Operation No.” := FORMAT(‘1’);
RecRoutingLine.“Work Center No.” := “Work Center No.”;
RecRoutingLine.“Work Center Group Code” := “Work Center Group Code”;
RecRoutingLine.Type := RecRoutingLine.Type::“Machine Center”;
RecRoutingLine.VALIDATE(“No.”, “No.”);
RecRoutingLine.INSERT;

RecMachineCenter.RESET;
RecMachineCenter.SETRANGE(“No.”, RecRoutingLine.“Routing No.”);
IF RecMachineCenter.FINDFIRST THEN BEGIN
RecRoutingLine.Description := RecMachineCenter.Name;
RecRoutingLine.MODIFY;
END;
END ELSE BEGIN
RecRoutingLine.“Routing No.” := RecItem.“No.”;
RecRoutingLine.“Operation No.” := FORMAT(‘1’);
RecRoutingLine.“Work Center No.” := “Work Center No.”;
RecRoutingLine.“Work Center Group Code” := “Work Center Group Code”;
RecRoutingLine.Type := RecRoutingLine.Type::“Machine Center”;
RecRoutingLine.VALIDATE(“No.”, “No.”);
RecRoutingLine.MODIFY;

RecMachineCenter.RESET;
RecMachineCenter.SETRANGE(“No.”, RecRoutingLine.“Routing No.”);
IF RecMachineCenter.FINDFIRST THEN BEGIN
RecRoutingLine.Description := RecMachineCenter.Name;
RecRoutingLine.MODIFY;
END;

END;

It still does not work…

Where did you write this code?

Never tell us that it is not working…

tell us the exact problem that you are facing…like error message…some fields not updated etc…

Sorry…

Basically, I want to run this dataport (this code is in OnAfterImportRecord), and the only thing that it’s not doing is showing the name of the work center (“work center” table, “name” field) on the routing line form (“routing line” table, “description” field).

It should show up automatically after validating the No, like it does in the form (although it only does that after pressing the lookup arrow, not by just pressing enter)…

If you want to show Work Center name in Routing Line description why are you getting machine Center detials?

you need to get Work Center Details and Assign work center name to Routing Line Description…is n’t it?

Oh man, today’s not my day…

I didn’t mean work center, i meant machine center. I want to access the details of the machine center table, namely the name field. The code is correct, or it should be.

Sorry, once again…

Did you try with

RecMachineCenter.RESET;
RecMachineCenter.SETRANGE(“No.”, RecRoutingLine.“Routing No.”);
IF RecMachineCenter.FINDFIRST THEN BEGIN
RecRoutingLine.Description := RecMachineCenter.Name;
RecRoutingLine.MODIFY;
END;

I tried by running your code in report and it working fine without above and worked fine because of

RecRoutingLine.VALIDATE(“No.”, “No.”);

did you get anu value in description or it is blank?

do you have value in name field of respective Machine Center?

I also thought it was enough to use validate, but since it didn’t work, I tried this solution, and apparently, it also does not work…

So you can make the Machine Center name show up in the Operating Line form (description field)?

You mean Routing Line?

Yes, I can see machine Name value in description field.

Did you check name field of machine center? does it has any value?

It’s blank.

The values are all filled in the Machine Center table…

What is blank?

Name of machine center or description field of Routing Line?

If Name of machine center then enter some value in that and try with

RecMachineCenter.RESET;
RecMachineCenter.SETRANGE(“No.”, RecRoutingLine.“Routing No.”);
IF RecMachineCenter.FINDFIRST THEN BEGIN
RecRoutingLine.Description := RecMachineCenter.Name;
RecRoutingLine.MODIFY;
END;

or simply RecRoutingLine.VALIDATE(“No.”, “No.”);

The description field of the routing line form is blank, the name field of the Machine Center table is filled

Check with Messages…

RecMachineCenter.RESET;
RecMachineCenter.SETRANGE(“No.”, RecRoutingLine.“Routing No.”);
IF RecMachineCenter.FINDFIRST THEN BEGIN

Message(’%1’,RecMachineCenter.Name);

RecRoutingLine.Description := RecMachineCenter.Name;
RecRoutingLine.MODIFY;
END;

Message(’%1’,RecRoutingLine.Description);

Funny, the first message does not show up, but the second one shows the correct values. They just don’t appear on the form…

How many lines you have in routing Line?

To know exactly for which we are getting the messge.use

RecMachineCenter.RESET;
RecMachineCenter.SETRANGE(“No.”, RecRoutingLine.“Routing No.”);
IF RecMachineCenter.FINDFIRST THEN BEGIN

Message(‘Machine Center name: %1’,RecMachineCenter.Name);

RecRoutingLine.Description := RecMachineCenter.Name;
RecRoutingLine.MODIFY;
END;

Message(‘Routing Line description : %1’,RecRoutingLine.Description);

How many lines do I have for Routing Line? Each item has one or more lines. Don’t really know exactly how many in total (for example, the item I’m testing has two lines)

The only message that shows up is the routing line description, the machine center name does not show up…