purchase order form

as per the above pic i have added a field as Emp id in general fast tab with values 2555, i want this same values in Lines fast tab where i have also added a field as Employee id , could anyone tell me how to perform this operation. The above picture is the screenshot of purchase order page while adding a new entry.

Hey Bittu Guha,

It’s very simple just write below line of code - On the OnValidate Trigger of EMP ID

Make PurchaseLine a local Variable.

PurchaseLine.SETRANGE(“Document Type”,“Document Type”);
PurchaseLine.SETRANGE("“Document No.”,“No.”);
PurchaseLine.“EMP ID” := “EMP ID”
UNTIL PurchaseLine.NEXT=0;


See how the function “UpdatePurchLines” is used in table 38 and then modify that function to handle your new field and call in the OnValidate of your new field in the header.

hi rockwithnav thanks for the suggestions, but it is not working, could you please give me an another suggestion

Hi Bittu,
[mention:0d5d5a12a38749cf82d5992cf1f92071:e9ed411860ed4f2ba0265705b8793d05] showed you how to do it (the beginner way) and @babrown told you how to do it the “correct” way. Not sure what else to tell you… [;)]
If it’s not working, then it’s because you didn’t follow their advise. Or maybe didn’t understand what they suggested?

Can you please tell us what you did and where you did it?

Hey Bittu,

Erik said it very correctly, we should always follow as per the standard NAV and what @Babrown suggested was the most recommended way but it requires more attention and carefulness to touch standard piece of code without affecting it with full root cause analysis and that’s why I advised something like this.

Please let me know If we understood something wrong because I believe there’s no way that it shouldn’t work or if you have some different requirement.

hey rock ,

i have tried this particular code you suggested in the on validate of emp id in purchase header table and i have also declared purchase line in c/al local as you have suggested before. it is not working

PurchaseLine.SETRANGE(PurchaseLine.“Document Type”,“Document Type”);
PurchaseLine.SETRANGE(PurchaseLine.“Document No.”,“No.”);
PurchaseLine.“Employee Id”:=“Emp Id”;
UNTIL PurchaseLine.NEXT=0;

The code is fine. What part doesn’t work?

May I suggest that you try to run the debugger and see why it doesn’t work.

Right now I can see your next issue. Because unless you’re also updating the OnValidate for the “No.” field on the lines, then the field value is being removed., whenever you create a new line or changes the type (it’s part of Type’s onValidate code - but don’t remove that!).

Hi Bittu,
I think what you were missing is you haven’t taking the values in Subform…
What I would Suggest is Write this code on Page 54 i.e Purchase Order Subform of Field
No. Onvalidate
IF PurchHeader.GET(“Document Type”,“Document No.”) THEN
“Employee No” := PurchHeader.“EmpNo.”;

Try above Code and let me know if it helped or Not