How to hide timeline control action buttons

How to hide timeline control action buttons

Dynamics 365 CE has really nice timeline control. It comes out of the box and has extensive configuration options. It is written using PCF (PowerApps component framework) and  even able to show your custom activities.

But it has one downside. Unfortunately action buttons bar isn't customizable and doesn't respect beloved RibbonDiff. Still clients would like to hide specific buttons from users in case when there is additional validation and logic implemented on form or via ribbon button. There is exact question on how to do it on Dynamics community forum: So lets hack it!

Timeline control stores action buttons definitions in MscrmControls.TimelineWallControl.Utility.CommandFactory.ActivityCommands object. These buttons' objects and names are hardcoded, but you can replace them with empty object and control won't render them. I had to use setInterval (line 4) cause during form onLoad execution custom control might not be loaded yet. And we have to wait. The other tricky part is refreshing control (line 13). When we substitute command control is actually rendered on form with all original buttons. So we have to trigger re-rendering :)

You can use it on your form onLoad event: TimelineWallControl.HideCommand("Delete").

That's all. Please note this is completely not supported and may broke after any minor update (or no) and provided AS IS for educational purposes.