Dynamics 365 Business Central: object prefix for AppSource extensions Q&A

Answers to a post-course question regarding object prefixes in extensions for AppSource:

  • Object prefix must be registered with Microsoft (at least 3 digits) and must be unique (it’s globally reserved for you)
  • It can be a prefix or a suffix (you can call an object XXXMyTable or MyTableXXX)
  • You have to use it for every objects in your extension
  • This is case insensitive (you can call an object XXXMyTable or xxxMyTable)
  • You can use the prefix in any format you want (XXX_MyTable, XXX-MyTable, XXX.MyTable, XXX MyTable etc. are all valid names)
  • You can register more than one prefix (you can have a prefix for app but I think this is not a good way to do, I prefer a prefix for company)
  • Functions in your extension objects cannot have the prefix/suffix in names (the prefix is in your object name, so you can have something like XXX-MyCodeunit.MyWonderfulFunctionNameLongAsIWant() )
  • If you have extension A that depends on extension B and extension C, and both B and C adds a function MyFunction to a standard table (Customer table for example), if you call Customer.MyFunction you receive an error on compilation (ambiguous call)

This is all what I know regarding prefix/suffix rules. Feel free to add if you know more 🙂

P.S. My absolutely personal opinion: I’m not a fan of object prefix/suffix. I think this is something not very “elegant” and clean and for me it’s only a simple workaround against a big lack in the actual AL framework: the missing of namespaces.

A namespace is designed for providing a way to keep one set of names separate from another. The class names declared in one namespace does not conflict with the same class names declared in another.

I think we have to copy something from C#:

using System;

namespace name1 {

  class MyClass {

    public void func() {

    Console.WriteLine("Inside name1");

    }

   }

}

namespace name2 {

  class MyClass {

    public void func() {

    Console.WriteLine("Inside name2");

    }

  }

}

class TestClass {

  static void Main(string[] args) {

  name1.MyClass class1 = new name1.MyClass();

  name2.MyClass class2 = new name2.MyClass();

  class1.func();

  class2.func();

  Console.ReadKey();

  }

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.