CMS 10.6 Custom Macros


Prerequisites:

  • CMS 10.6 must be installed. See CMS Statistics for details to check your version.
  • Access to modify and update the CustomHooks.cs file for your CMS instance. To add custom macros to the file, see CMS 10.6 Adding Custom Macros for details.

Previous CMS versions required the custom hook code to associate with an individual custom hook action (e.g., Rename, New Page, Publish, etc.), where users required direct custom hook file access to run the code.

CMS 10.6 provides features for administrators to run pre-defined custom hook functions from the CMS UI interface without direct custom hook file access. Administrators can execute these functions on-demand with an executable macro. A custom macro is functionally similar to a custom hook. However, the custom macro is triggered by a UI button click (i.e., the Execute button) or Web API call instead of a CMS action.

Access available custom macros by navigating to Administration > Maintenance > Custom Hooks and selecting the Macros tab. This tab provides a list of available custom macro functions. Each entry has an Execute button. Administrators click this button to run the custom hook code directly from the CMS UI.

Troubleshooting
  • Custom macros have limitations. Custom macros do not have access to HTTP.Context. Also, custom macros have the same limitations as custom hooks. For example, if the custom macro has external references, those references need to be included in the external harness project references.
  • If custom macro functions are missing from the list, select the Refresh button Refresh Button

    to reload the functions. If the functions still do not display, review your hookup script code in CustomHooks.cs for discrepancies.

  • Custom macros interact with Web API. Consider testing macros to help minimize maintenance and to help ensure the code runs as expected before fully running your custom macros.

Custom Hooks File Viewer

By default, the CMS automatically provides the following custom macros as samples:

Send a Message
When executed, the custom macro function sends a simple message to the CMS.
Count
When executed, the custom macro function runs a count, starting from one and ending at twenty.

When you click the Execute button, the CMS runs the custom macro function and opens a dialog to indicate the macro in progress.

For example, when you click Execute the Count custom macro sample, the I am Counting dialog displays, indicating the item number and the time when each count entry took place.

Count Custom Macro Dialog

Note
Keep in mind that this dialog functionality varies, depending on your custom macro configuration. Some custom macros may indicate progress updates while others may not (e.g., the Send a Message custom macro).