B1UP Tutorial Series: Macro Best Practices feat. Penny Oleksiak! (sort of)
? Video Description
These are my best practice tips and tricks for writing the best macros possible for SAP Business One and B1 Usability Package Universal Functions.
Features a Penny Oleksiak puppet that I cut out from a Cherrios box to entertain my kids.
? List of Best Practices
1. Titles - I name my B1 Validation and Universal Functions like: ORDR: Name of Function (Sales Orders), OXXX: Name of Function (any document), MENU: Name of Function (menu item), etc. Give your functions meaningful names, makes it quick to identify where the function is being used. (You can also use the Universal Function \\ Right-Click \\ Where is this UF used?)
2. Comment / Document Your Code - Especially if you do lots of macros you won't remember the item IDs or the specific functions of all your lines of code. It's a really important best practice to write comments above or after your lines of code.
3. Use Categories - Once you categorize your B1 Validations, Universal Functions, Function Buttons, Item Placements, etc. it makes it easier to keep them together, export them and manage your various systems. Go to a category and push "Overview" to see all things related to your functions.
4. Use Effective Dynamic Syntax - See my previous video (
https://youtu.be/JDir4Ogqfvg) on Dynamic Syntax (shortcuts and C# snippets). I don't want to see stores pulling OCRD columns from documents for example, use row references .FOCUSED, etc. Name your IPT fields so they are the same across documents. Just type over the auto-generated code in the IPT.
5. Combine Functions Per Trigger - You can supposedly layer over multiple B1 Validations and then use the "Sort" number to indicate which one is supposed to be run first. But it's easier to just load a single macro and do your evaluations all at once. I don't want to see four B1 Validations running on the same field!
6. One Function for All Form Types - Don't make a B1 Validation per document, just run the same validation on all documents and filter in the macro to run the right code. Especially if the code is 90% the same. View my Dynamic Syntax tips & tricks video for more details on how to filter for the form type. Add a ";" semicolon to use multiple form types on one validation.
7. Freeze(); / UnFreeze(); - This is so essential. You need to freeze the screen so you don't see each movement of the mouse. Each time you activate a new form you need to use Freeze(); and then UnFreeze(); at the end.
8. Watch Form Modes - Make sure you match your functions and item placements to the right form modes. If there is no reason to run your functions in "Add" mode then don't have them set to run. It your item placements shouldn't be active in certain modes disable them. Don't use "All" for all your B1 Validation setup
...
https://www.youtube.com/watch?v=K113_C2qpZE