Article

How to do an emply space in macros just in case the value is not filled in

Hello!

 

In this article, we will describe how to work with macros and filling in the values.

 

This functionality was added specifically so that the user could clearly see that there are no values in these fields and that it is necessary to manually edit such an email before sending it.
 

To solve this issue, you can configure the mandatory filling of the fields used in the template for the template to be sent correctly.

Also, as part of sending emails through a process, you can add additional logic to the process itself by setting up two branches (containing and not containing data) using two email templates:
1) with macros
2) without macros
 

In general, to resolve the issue, make these fields mandatory when creating a record, or edit emails before sending them (in the process, check the “Send email manually” box for the [Send email] element), or reconfigure the process by creating two branches as described above.

 

Also, there is another way to resolve it.

 

In the business processes and bulk emails, macros are already empty when the data is not filled in. In the UI you would need to do the following to remove the macro description: 

You would need to create your own service, copying InvokableMacrosHelperService, change macrosHelper instantiation to use Factory: 

            var macrosHelper = new InvokableMacrosHelper { UserConnection = UserConnection };
to 
            var macrosHelper = ClassFactory.Get()
After that, you would need to override the ReplaceMacros(string template, List macrosInfo) method in class InvokableMacrosHelper (using [Terrasoft.Core.Factories.Override]) to change the macro to an empty value instead of a highlight instead:
 protected override string ReplaceMacros(string template, List macrosInfo) {
      string result = template;
      foreach (MacrosInfo item in macrosInfo) {
        string macrosDisplayValue = string.Format(MacrosTemplate, item.Alias);
        result = result.Replace(macrosDisplayValue, "");
      }
      return result;
    }

You can find an original method in MacrosHelperV2. After that, you would need to change the calls of the service from OOB service to your service in the action dashboard or email page. 

Like 0

Like

Share

0 comments
Show all comments