I am attempting to create a selectable column on the sales invoice page using a boolean in visual studio code, but having trouble. Does anyone have any suggestions on the correct coding to make this possible? I also created this field on the customer card and will like for it to be linked to the column in the sales invoice. How would I go about that? Below are some pictures that can show my progress so far. Thank you.
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; }
Would I include this in the field bracket under caption and editable? Or begin after line 16? Could you also include the correct brackets it seems that I am getting a lot of errors.
You should subscribe to this event in the sales header table:
[IntegrationEvent(false, false)]
local procedure OnValidateSellToCustomerNoAfterInit(var SalesHeader: Record "Sales Header"; xSalesHeader: Record "Sales Header")
begin
end;
And there you can populate the salesheader with the value from the boolean field from the customer.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,232 Super User 2024 Season 2
Martin Dráb 230,064 Most Valuable Professional
nmaenpaa 101,156