Entity Event Installation Bug in the Infor CRM 8.5 web entity model

I have recently come across a bug a couple of times now that I thought important enough to discuss to hopefully help others from pulling out all of their hair trying to troubleshoot an issue that never should have become a problem. The issue is that entity events (OnBeforeUpdate, OnCreate, etc.) never seem to get wired up to the Entity they belong to, and thus never get implemented when the web portals are deployed.

I have seen this happen twice when installing custom entity events into an existing entity in another system. It is a tough thing to discover as no errors happen, it is just that the code running during these events never occur. I have not found an elegant way of fixing this, but there is a way to fix it. Before I get into that let’s discuss how this stuff actually works.

When you build the web platform, one of the things that the Application Architect does for each entity is to wire up the entity events that occur for the entity. This happens within the implementation folder of the defined Build folder. Inside this implementation folder there are separate cs files for each Entity. For example there is an Account.cs for the Account Entity, an Opportunity.cs for the Opportunity entity, and so on. If you edit one of these files in a text editor and search for “CRUD” you will see a section like:

#region CRUD events
        protected override void OnAfterInsert()
            DynamicMethodLibraryHelper.Instance.Execute("Account.OnAfterInsert", new object[] { this });

        protected override void OnAfterDelete()
            DynamicMethodLibraryHelper.Instance.Execute("Account.OnAfterDelete", new object[] { this });
#endregion CRUD events

The problem I ran into was, for the entity where I was adding custom events, this section lacked any definition for my custom events. It just looked like:

#region CRUD events
#endregion CRUD events

And as imagined, since the entity was built without the definitions for the entity events, once I attempted to test the code in the deployed site there was nothing happening since the deployed entity model did not contain the entity with my custom events wired up.

Why was this happening?

While waiting for the ponderous build and deploy cycle is bad enough (with the intolerable out of memory bug-a-boo thrown in to rip out more of your hair), to age through that, only to find that something did not happen that should have is like a kick in the gut by a mule. Well maybe at least a kangaroo…

It turns out that there is a bug where the Entity is not correctly being altered. To understand that you need to understand how an Entity is actually stored in the Entity Model:

  • Each entity is defined as a xml file within the model. The file is named in the format of {Entity Name}.{Table Name}.Entity.xml. So for the Account entity it would be “Account.ACCOUNT.entity.xml”.
  • Then each entity event is stored in its own XML file, such as “OnBeforeInsert.method.xml”.
  • Finally the code within each entity even can be stored in its own file which is in the format of “Sage.SnippetLibrary.CSharp.@.{GUID}.codesnippet.cs”.

Simple enough for you? Yeah…and you wonder why the builds take so long.

To see these files in the database-based VFS you can open the Application Architect and open the Virtual File System Explorer (Control+Alt+F).  If you are using a file based VFS, these files are accessible via the normal file explorer.  In the Virtual File System explorer you would expand out the Model folder, then the Entity Model folder, and finally the correct package folder (typically “Saleslogix Application Entities”).  Inside this folder is a list of all the Entities in that package (such as Account, Contact, etc.).  Expand out the appropriate folder and you will then see the files I previously mentioned.  Here is an example of the Account entity folder.

When installing custom events what you end up with in the folder is the custom event files showing up (such as “OnBeforeInsert.method.xml”) but what fails to happen is the entity itself fails to get updated, i.e. the Account.ACCOUNT.entity.xml file.


Lets take a look at what this entity file looks like.  At the top of this file is the main “header info” of the entity, in a tag called surprisingly “entity”.  This contains such attributes as:

  • Is it under Managed Schema
  • Table Name
  • Entity Name

Also in this header section should be hooks where the entity events are wired up.  These are on the format of the event name + “Id” with the first letter in lower case, i.e. the OnBeforeInsert event would be “onBeforeInsertId”.  In the case of installed custom events on existing entities these wired actions do not get added to the entity model file.  What you can do to fix this is to add these hooks manually.

Be careful following the steps I am about to give.  Incorrectly modifying these files can lead to them no longer working.

The first thing you need to do is to find the GUID that represents the action you need to add to the entity.  This can be found by opening the corresponding entity event file in the Virtual File System Explorer.  Every event file (like OnBeforeInsert.method.xml) contains a similar header row at the top of the XML where it contains the Name attribute (like OnBeforeInsert).  One of the other header attributes is an id attribute that stores a GUID value.  Once you open the entity event method file, copy the id’s GUID value to your clipboard.

Now go back to your main entity file (like Account.ACCOUNT.entity.xml) at the end of the <entity> tag add the appropriate entity event action name (like “onBeforeInsertId”) followed by an = and then in double quotes add the GUID you copied from the associated event file.  The end result should look like this:

<entity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="fdbf6aa0-a592-4081-a6f7-e78b6263f070" isCustom="false" lastModifiedUtc="2021-07-20T01:51:18.6222357Z" manageSchema="true" tableName="ACTIVITYASSOCIATION" name="ActivityAssociation" displayPropertyId="3669d196-03d7-407e-a79c-7a3f3928d8a6" isExtension="false" audited="false" onAfterInsertMethodId="13bc2a5b-b5d4-4dc3-bccc-1c2e39218faf" onAfterUpdateMethodId="5731c388-8e23-477b-956a-a3475ca7cf1e">

After you do this save the changes to your entity.xml file.

Close and then re-open application architect.

Do a build of the web platform. Your entity will now correctly get the event wired up to it and your code will run successfully.

I think the reason for this is when adding your custom events to the bundle, the web manifest is built with the action to install your custom event files but is failing to then associate these new events to the existing standard entity file. This is a big bug that Infor needs to fix ASAP as having to manually update xml files like this is a tedious recipe for disaster.

Want content like this delivered to your inbox? Sign up for our newsletter!

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

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