Field renaming and subscribers

By now everyone is using or should be using subscribers, so whats there to write about, right? Or at least there should be enough posts out there if something fishy emerges that someone has already written about it. This is no different. I found this problem covered in Punkys blog ( but still i wanted to share my thoughts about it.

So to summarize the problem, if you subscribe to a table field (for example OnAfterValidate) and later someone (or you) renames the field, subscriber will not be updated. Or to be more exact, field onto which you subscribed will not be renamed in the subscriber. Why was i surprised at first? Because, the old-school developer in me is expecting everything to be updated. Why? Because, as we know, every field in the table is uniquely identified by its ID and Name. So renaming a field will simply find the field usage by its ID and rename it properly. Ok, this is not entirely true, but in general this happens (i’ll not go into details why this is not always true).

Lets have a look at this easy example and dig further into this.

This is a simple Test table.


And this is a subscriber:


Lets have a look how the subscriber looks in .txt:


In EventSubscriber line we can see a summary of subscriber properties: EventPublisherObject, EventFunction and EventPublisherElement.

As you notice, table is reffered by ID where field is reffered by its name. No wonder subscriber can’t be updated with new field name as other unique element is missing, field ID. If you think about it, this approach is something Microsoft has already implemented in AL code in VS Code – table fields are reffered by their Name only (credits to Vjeko for pointing this out). So not sure if this will ever be fixed/updated.

Let’s go a step further and see what happens if we rename a table. Seeing how in the subscriber, table ID is used instead of the Name, it should automatically update the subscriber as well. This indeed happens.

How about renumbering the field? Subscriber will work fine. Since the name didn’t change there was nothing to update. There will be other error though that table MetaData is not in sync, so after compiling the object can be used.

So be carefull when renaming a field in a table, you’ll not be warned about the existance of any subscriber related to the field you’re renumbering/renaming.