Live is simple if you know how – C&P chapter 2

And that brings me to chapter 2. Maybe less exciting, but for sure even more fun than the preceding chapter if you didn’t know about it yet. Saves you a lot of time.

One of the things I have always liked about NAV is the open source character of it. OK, you need the right license, but as soon as you have it you can look at any part of the code. And one of the things I probably did stress most when teaching Solution Developer classes was: if possible reuse existing code. Your customer does not want a state of the art unique piece of code, your customer wants a reliable solution! So C&P. C&P code snippets. C&P functions; C&P whole objects.

C&P functions? Yes, here we go.

Let’s say you would like to implement the same AssistEdit functionality as can be found on the Customer Card (21): the button in the No. field.
Digging a bit into the code you did find that a AssistEdit function has been defined on the Customer table (18). Now you would like to reuse that code. You know how to create functions in any object; you know how to provide it with the right parameters, return value settings and local variables. So you could do that and C&P the code lines from the AssistEdit function on the Customer table to your object. Maybe you have done that dozens of times before and found every now and then that you had overlooked some local variable or parameter. Indeed we’re no machines and our actions are error prone. So let C&P be your friend!

  1. On table 18 (Customer) in design mode open the C/AL Globals window and select the Functions tab:

  2. Select the AssistEdit line (record!)
  3. Ctrl+C (Copy)
  4. Go to your object that you are designing
  5. Open the  C/AL Globals window
  6. Create an new line and …
  7. … Ctrl+V (Paste)

Your object is now the happy owner of an AssistEdit function, including parameters, return value settings and local variables. Congratulations! [^]


As your context might be a bit different from the one on the Customer you probably need to do some updating on the code.

One Comment

  1. You're fully right. Thanx for correcting my omission. 😉

Leave a Reply

Your email address will not be published. Required fields are marked *