Update field in sales line after sales header field filled

How to automatically update field in sales line records after i filled sales header field ?

My sales header and sales line have this new field called Ext_Doc (Code).

If i create a new sales order and fill this field in sales header with ABC is there a formula so this will update fieeld in every record sales line in that sales order to ABC too?

Sory for my bad english.

You need to write a code on Onvalidate trigger of Your Custom field by taking Sales line table as reference.

Look at Location code field on Sales header table for reference and how it is updated it in sales line table

I see. Thanks for the referrence i will look there and see if i can put code there.

All the Best! Let us know

Thanks for your earlier response amol. I tried to write code for Ext_Doc same as code for Location.

After that, everytime i update the Ext_Doc on sales header the system show this.

You have changed Ext_Doc on the sales header, but it has not been changed on the existing sales lines.

You must update the existing sales lines manually.

And sales line’s Ext_Doc didn’t update automatically.

Do you have other suggestion for other code than this ? :slight_smile:

Can you show us your code and was the sales header open or released when you entered a value into your new field?

I think you have copied existing code of location code field

Look at this line of code MessageIfSalesLinesExist(FIELDCAPTION(" "));

This line showing the message whenever user is trying to change desired field .Now if you want to update the field on sales line then tell user to click on ‘Yes’ button to update the same or comment the code .

Test it properly before releasing to user.

Amol’s example is wrong. The Location Code field does not update on the lines. The message does not give you the choice to update the lines, there is only a message that you will need to update the Location Code on the lines manually.

There is a function called UpdateSalesLines in the Sales Header table that takes care of updating related sales lines. You will need to add logic to that function to take care of the custom field, and add a call to the function to the OnValidate of the custom field. Take a look at how this works with the Shipment Date field in the Sales Header table.

Hi Denster,

Yes I am wrong I gone with my customized message .I am extremely sorry for that and thanks for pointing it out.

Hi Lie ,

I am extremely sorry for giving wrong reply as we customized the same for client.

Kindly follow Denster reply for resolution of your queries.

Amol: how can you miss the customization, do you not tag custom code with comments?

Hi amol, It’s ok. :slight_smile:

i really appreciate your will to help.

I will try it. Thanks denster for pointing us the mistake. I will post my result here once i’ve triad it. :slight_smile:

It is marked with comments but while replying I forgot …

Sorry again.

@Denster & Amol,

I’ve tried your suggestion about shipment date and it worked. Here are some code i add in sales header and sales line.

Ext_Doc - Onvalidate() //this one on sales header

UpdateSalesLines(FIELDCAPTION(Ext_Doc),CurrFieldNo <> 0);



IF SalesLine.“No.” <> ‘’ THEN


CheckItemAvailable //this one on sales line

IF Ext_Doc = ’ ’ THEN BEGIN


IF SalesHeader.Ext_Doc <> ‘’ THEN



VALIDATE(Ext_Doc,’ ');


After i put those code everytime header updated, line updated too. Thanks!! :slight_smile:


A little bit correction for my previous post, this codes doesnt needed. Just the one on sales header. :stuck_out_tongue:

CheckItemAvailable //this one on sales line

IF Ext_Doc = ’ ’ THEN BEGIN


IF SalesHeader.Ext_Doc <> ‘’ THEN



VALIDATE(Ext_Doc,’ ');