Running code in OnAfterValidate trigger

Hi On the Sales Quote form I have code on the “Sell-to Customer No.” OnAfterValidate trigger. This runs a Confirmation form passing a parameter of SalesHeader, if You Select Yes then a second form is run displaying any Outstanding back order sales lines, and you select any lines you want and the rest the quantise are reset or lines deleted depending on what posted. If you say No on the confirm form then all the outstanding lines are reset or deleted. This is OK when the form is called from the S&R menu but when the form is called form the Sales command button of the Customer card I cannot fire the code on the “Sell-to Customer No.” OnAfterValidate trigger. I have tried putting code on the OnInsert trigger of the “Sales Header” table but I can’t seem to be able to pass the correct Sales Header parameter on to the Confirmation form Can anybody help?

Try the same code on Onvalidate of Sell-to Customer No.” in Table sales header.

Girish Thanks, but I have already tried that as well. The problem seems to be that one of the functions on the forms being called returns “Sales Header does Not exist”. It is fine when you call the Sales Quote from the S&R menu because you fire the OnAfterValidate trigger on the form where you can SAVERECORD and COMMIT when the “Sell-to Customer No.” is keyed in.

[:)] Problem Solved.

Yes but how did you solve it?

This the code I had to enter onto the “Sales Header” OnInsert trigger. // SG1.05 Begin // IF GETFILTER(“Sell-to Customer No.”) <> ‘’ THEN // IF GETRANGEMIN(“Sell-to Customer No.”) = GETRANGEMAX(“Sell-to Customer No.”) THEN // VALIDATE(“Sell-to Customer No.”,GETRANGEMIN(“Sell-to Customer No.”)); IF GETFILTER(“Sell-to Customer No.”) <> ‘’ THEN IF GETRANGEMIN(“Sell-to Customer No.”) = GETRANGEMAX(“Sell-to Customer No.”) THEN BEGIN VALIDATE(“Sell-to Customer No.”,GETRANGEMIN(“Sell-to Customer No.”)); IF (“Document Type” = “Document Type”::Quote) AND NOT “Disallow Back Orders” THEN QuoteGetBackOrders; END; // SG1.05 End QuoteGetBackOrders(); SalesQuoteHeader := Rec; SalesQuoteHeader.INSERT; IF BackOrderMgt.OutStandingOrdersFound(SalesQuoteHeader) THEN BEGIN COMMIT; BackOrderMgt.ConfirmBackOrders(SalesQuoteHeader); END; SalesQuoteHeader.DELETE; Rec := SalesQuoteHeader; Thanks to Emiel for his help with this.