RE: Correct coding in Visual studio code for boolean in Business Central
First of all i think you probably want to extend the Sales Header table with your new field and not only the sales Invoice Header.
The sales Invoice Header is the posted document. And you probably want to set you field on the sales header and then let it flow to the sales invoice header from there.
Then you need to add a codunit as i show here. The codeunit subscribe to the event and do the needed changes to the salesheader.
Then make sure your new field have the same field number in both the sales header table and the sales invoice table. If that is the case the standard posting function will make sure the value is transferred from the sales header to the sales invoice.
codeunit 90012 EvenSubscriberSalesHeader
{
[EventSubscriber(ObjectType::Table, Database::"Sales Header", 'OnValidateSellToCustomerNoAfterInit', '', false, false)]
local procedure OnValidateSellToCustomerNoAfterInit(var SalesHeader: Record "Sales Header"; xSalesHeader: Record "Sales Header");
Var
Customer: Record Customer;
begin
Customer.get(SalesHeader."Bill-to Customer No.");
SalesHeader."Customer Invoice Required" := Customer."Customer Invoice Required"
SalesHeader.Modify(True);
end;
}