Posting
Let's have a look at the posting routine that we can create to move data from the Documents to the Document History while creating Example Entries:
The Codeunit Example-Post 50000 is engineered with a concept called Natural Language Programming that we will discuss in the next chapter, Chapter 5, Coding Best Practices. The OnRun
trigger does not contain any business logic code, it only explains in readable English what steps will be processed. Let's look at some of the steps.
The ThrowErrorIfNoSelection function
When the Codeunit is called, we need to know which history document to create. This is done using the Select fields. If none are selected, we need to throw an error:
WITH ExDoc DO IF NOT (One OR Two) THEN ERROR( NoSelectionError, FIELDCAPTION(One), FIELDCAPTION(Two));
The TestNear function
Before starting I/O to the SQL Server, we need to do some basic testing to see whether the Documents contain mandatory data. This is preferably...