Last active
June 14, 2020 12:19
-
-
Save DanKinsella/3843291017e7a6d8a8ed1b60ee311383 to your computer and use it in GitHub Desktop.
Creating an LS Central POS command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
codeunit 50100 "LS POS Command Demo" | |
{ | |
TableNo = "POS Menu Line"; | |
trigger OnRun() | |
begin | |
if Rec."Registration Mode" then | |
Register(Rec) | |
else | |
case Rec.Command of | |
GetHelloWorldCommand(): | |
HelloWorld(); | |
end; | |
end; | |
local procedure Register(var POSMenuLine: Record "POS Menu Line") | |
var | |
POSCommandReg: Codeunit "POS Command Registration"; | |
ModuleDescription: Label 'DanKinsella.blog - Demo'; | |
HelloWorldCommandDesc: Label 'Say hello to the cashier.'; | |
begin | |
// Register the module: | |
POSCommandReg.RegisterModule(GetModuleCode(), ModuleDescription, Codeunit::"LS POS Command Demo"); | |
// Register the command, as many lines as there are commands in the Codeunit: | |
POSCommandReg.RegisterExtCommand(GetHelloWorldCommand(), HelloWorldCommandDesc, Codeunit::"LS POS Command Demo", 0, GetModuleCode(), true); | |
POSMenuLine."Registration Mode" := false; | |
end; | |
procedure GetModuleCode() : Code[20] | |
var | |
ModuleCode: Label 'DANKINSELLA.BLOG', Locked = true; | |
begin | |
exit(ModuleCode); | |
end; | |
procedure GetHelloWorldCommand() : Code[20] | |
var | |
HelloWorldCommand: Label 'HELLOWORLD', locked = true; | |
begin | |
exit(HelloWorldCommand); | |
end; | |
procedure HelloWorld() | |
var | |
HelloWorldMsg: Label 'Hello World!'; | |
begin | |
Message(HelloWorldMsg); | |
end; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment