Integration is always a delicate balance sending information from one system to the next. Most of the time you would only need to send a subset of the actual data that you've stored within the source system. With the use of the Content Hub, this is not different. In this blog post we're going to talk about sharing information via the service bus.
Within the Content Hub, there's a default connector to send messages via an Azure service bus. Most of the time the message that needs to be sent is pretty straightforward. But as always, there are some edge cases that require some tweaking. Today, I received a question about settings the headers on a service bus message. By default, the Content Hub only allows access to the context of the modified entity. That context will only get you so far. It only extends to the properties and relations of the entity, as you can read in the documentation.
So what to do when you want to have access to fields like created_on or modified_on, etc? At a first glance, this seems to be rather annoying. Why can't we just use this {modifued_on} selection to get the value into the header. Not sure why Sitecore doesn't support this, but we have a solution.
Promote the value to a property.
When you extend the schema with a property it will become available to be used in the service bus. How will we keep the property up to date? Well by using the default mechanism within the Content Hub of course. For this, we can create a trigger that will be executed on each entity modification. It will trigger an action that will run a script. The script will fill the property with our field value. When settings up the action, make sure to set the Execution type to "In process". This will ensure the property is updated before the service bus action is triggered. Otherwise, the service bus message could be sent before the property is updated.