I am trying to make some fields mandatory. For instance I would like the Customer PO feild to be mandatory in Sales Orders. I know that in the code you you just set the field to ShowMandatory = true; But how do you add that property to a core field?
add tesfield(“Customer PO”) when you release the sales order.
So where in the code do I put this? Do I make a Page extension? So if I have this:
pageextension 90001 MyExtension extends “Sales Order”
{
layout
{
// Add changes to page layout here
}
actions
{
// Add changes to page actions here
}
var
myInt: Integer;
}
Where do i put it in there?
No… you have to create a Codeunit and subscribe to some event in “Release Sales Document” codeunit… for instance, subscribe to OnBeforeReleaseSalesDoc event.
Best regards.
Just to close the loop on this, assuming you’re using the External Document No. as the Customer PO No. field, the Codeunit in question would look something like this:
codeunit 50000 "DUG Custom Event Mgt."
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Release Sales Document", 'OnBeforeReleaseSalesDoc', '', false, false)]
local procedure DUGOnBeforeReleaseSalesDoc(var SalesHeader: Record "Sales Header"; PreviewMode: Boolean; var IsHandled: Boolean; SkipCheckReleaseRestrictions: Boolean)
begin
SalesHeader.TESTFIELD("External Document No.");
end;
}
Naturally you can also make it a more tailored message by instead of using TESTFIELD to do an if statement (i.e. if SalesHeader.“External Document No.” = ‘’ then error(ErrorMsgTxt) or something to that effect.