I am trying to do a conditional validation before releasing a Sales Order. I want to base this off of a field we have created on the customer record, but I don't seem to be able to get the record. I am trying the below, and I get a message that gives me the customer number just fine, but the customer class (or any other customer record I try is coming up empty). I am hoping there is just something simple I am missing, any ideas?
CodeUnit 50305 /EventSubscriptions/
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::/Release Sales Document/, 'OnBeforeReleaseSalesDoc', '', true, true)]
local procedure ReleaseSalesDocument_OnBeforeReleaseSalesDoc(var SalesHeader: Record /Sales Header/; PreviewMode: Boolean; var IsHandled: Boolean)
var
Customer: Record Customer;
begin
if SalesHeader./Document Type/ = SalesHeader./Document Type/::/Order/ then
begin
Customer.get(salesHeader./Sell-to Customer No./);
message('Customer:' + Customer./No./);
message('Customer class:' + Customer./Customer Class/);