Creating Custom Macros To Format Values in Word Printables for Creatio (formerly bpm’online)

In Word printables for Creatio, it’s possible to create all sorts of custom macros to query and add related data, bring in values such as the current user, or just to format values. This article will look at creating a custom macro to format currency values in a Word printable, however the concepts are the same for any type of macro you’d like to create for Creatio.

The way a custom Macro for Creatio works is, you create a Source Code schema with a class that implements the IExpressionConverter interface. You define an attribute, which will be your macro’s name. Then, you can add that macro name to any merge field and when the printable is run, the value for the merge field will be passed to your code, you can do whatever you want with it, such as, simply format it, or use it to run a query and look up some other data to return, etc.

First, let’s create the macro. Again, our example will create a macro that just receives a currency value, formats it as money, then returns the formatted value to display in the Word doc. Add a new Source Code schema, give it a name of “UsrMoneyConverter” and add the following code:

namespace Terrasoft.Configuration
    using System;
    using Terrasoft.Common;
    using Terrasoft.Core;
    using Terrasoft.Core.DB;
    using Terrasoft.Core.Entities;
    using Terrasoft.Core.Packages;
    using Terrasoft.Core.Factories;
    using System.Globalization;
    public class UsrMoneyConverter : IExpressionConverter
        public string Evaluate(object value, string arguments = "") 
            return ConvertValue(value);
        private static string ConvertValue(object value)
            var result = string.Empty;
            if (value != null)
                result = value.ToString();
                double currency;
                if (Double.TryParse(result, out currency))
                    result = currency.ToString("C", new CultureInfo("en-US"));
            return result;

Notice the ExpressionConverterAttribute attribute on the class, it is defining the macro name as “Money”. The code simply receives a value, converts it to a double to ensure it’s a currency value, then returns the formatted value.

To use it, we’ll need to add it to a merge field in a Word printable. In a printable add any currency field, then right-click it and select “Edit field”:

You’ll see a dialog with the merge field where you can simply add [#Money#] to the end of the merge field name, like this:

Now, when that merge field is processed, it will pass the value to your code for the custom Money macro and the returned value will be what displays there in the Word doc.

While this sample was to simply format a value, we could use this same concept for other purposes as well. For example, you could add an Id for a record as a merge field, then when the Id is passed into your macro, you run a query to retrieve some other data and return that instead.

You can read more about creating custom macros in the Academy


Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

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

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!