Page with header and lines

Hi All.

I want to make page based on one table X with this structure: Header and lines.

In header there are Two fields(editable:yes) from the table X , and the values from this fields should be same for all lines. In the lines are the other fields from table X.

I tried with: 1. two Pages: Main and Subform (based on same table X) but in this case I can’t add values in a fields from Main Page (they act like not editable fields),

  1. page type Worksheet : the fields that should have same value for all lines I Positioned at the beginning (like in page Req Worksheet) ,but in this case I must add value in that fields for each line separately.

So how can I enable: when the value from header are added to be transferred to all records from the lines

Thanks in advance

Why don’t you check the Sales Invoice,Sales Order,Sales Quotes,Purchase Invoice,Purchase Order pages to get clarification.

I was following that examples, but in that case fields from Header act like a non editable fields, I can’t add value. Maybe the problem is because Main and Subform are based on a same table (not like in standard in two different tables, ex: Sales Header And Sales Line)

So is what you’re trying to build a sort of hiearachi? Like in the CRM with Contact of the Type=Person being part of a Contact Type=Company? It’s very difficult to imagine what you’re trying to do.

The examples you may need , check the General Journal Form. linking Journal Batch Name with Journal Lines.


Thanks all of You for reply, for better explanation I am sending a example how the page should looks. The field above (Return Reason Code) should have same value for all Items. When I choose Return Reason Code than automatically to be recorded for all lines below. (All fields are from same table). So far, when I am creating new line I can add different Return Reason Code for all lines, I need that to be replace with: when is choose value add that value for all items… (so not to be filtered by Return Reason Code))



So you want the value that you select as Reason Code on the Header, to be appeared as the default value of the Reason Code on every line that you will create afterward! You could do it in several different ways. Here is one way:

  1. First since there is a standard Return Reason table (ID=6635) already available in NAV, the best practice is to fill this table with some reason codes and their descriptions that fits your business, so you would add a Field (if page) or Text Box (if form) on the Header and link it to this table.

  2. Then create a new global variable on Header page (or form) that refers to Table 6635:






Return Reason

  1. Add a Field on your Header page (or Text Box if Form) and set its properties as follows:








Return Reasons



  1. So by now, if you test your header, it will popup the Return Reason Page/Form when you click on the control, where you can select a Code to be defaulted on lines later.

  2. Now you need to create two Functions, one in the Sub Form, so you can call it from the Header to pass the selected Reason Code from Header to the Sub Form upon selecting a reason code, and the other one in the Line Table, where you can call it from Sub From (e.g. Form-OnInsertRecord trigger) and pass the Code one layer down to the table. Here are how you define them:

  3. On the Sub Form, in C/AL Global, first define a global Code type variable called HeaderSelectedReasonCode and then create a new Function called UpdateReasonCode and then in its Locals, define a parameter called hReasonCode (DataType: Code). In the body of the function write:

HeaderSelectedReasonCode := hReasonCode;

  1. Save and close everything and go to your Line table design mode. Go to C/Al Global and create a new function called AddHeaderReasonCode and then in its Locals, define a parameter called hReasonCode (DataType: Code). In the body of the function write:

"Return Reason Code" := hReasonCode;

Save and close everything.

  1. Open your Sub Form in design mode again, and in Form-OnInsertRecord trigger add:


You could add the above code to other triggers as well if desired. However, the above trigger is enough for your purpose. Save and close everything.

  1. Open your Header Page (or Form) in design mode again, and in OnValidate trigger of the Field (or Text Box if Form) that you had added in the step (3) above, add the following code:


Instead of *** write your Sub Form control name!

  1. Run your Page (or Form), now on if you select a value for Return Reason Code on the header, each time that you create a new line, the selected Code will be defaulted in the line so you do not have to enter it on the line again.

If you save the Reason Code on your Header Table too, then you can omit step 1 to 4 and start from 5 and in step 9 also you can just write:

__CurrForm..FORM.UpdateReasonCode(<__your Header Table’s field name for Reason Code>);*

Instead of *** write your Sub Form control name!

Тhank You very very much