Hello everybody!
I am trying to create a document (as a PDF) that makes internal decisions using the Word IF statements and information fed to the printable via the printables mergefields.
For example, If the DownPayment is greater than a certain amount, additional paragraph is added to the document (i.e. {IF {MERGEFIELD <>}>=10000,"Amount shall be wired directly to...",""} This works in the document before making it a printable, but once I make it a printable this functionality no longer works.
Like
It would look something like this:
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; [ExpressionConverterAttribute("AmountMessage")] public class UsrAmountMessage : IExpressionConverter { public string Evaluate(object value, string arguments = "") { var result = string.Empty; if (value != null) { result = value.ToString(); double amount; if (Double.TryParse(result, out amount)) { if (amount >= 10000) result = "Amount shall be wired directly to..."; } } return result; } } }
Then add to the prinatable setup on amount field: Amount[#AmountMessage#] - the macro will evaluate the amount and return the message if amount is greater or equal to 10000, if not it will return a blank string.
Ryan
I had the same requirement and created a case for it two weeks ago.
The answer was that it is not possible at the moment and that Creatio is looking into it and adding it to their backlog.
As far as I know, Word printables are not working like the original Microsoft Word mail merge, but they are more of a search-and-replace mechanism using the same syntax.
I created the necessary fields in Creatio and prefilled them according to the IF logic with business processes...
I typically do that sort of thing in a custom macro and works great. See https://customerfx.com/article/creating-custom-macros-to-format-values-in-word-printables-for-creatio-formerly-bpmonline/
Ryan
It would look something like this:
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; [ExpressionConverterAttribute("AmountMessage")] public class UsrAmountMessage : IExpressionConverter { public string Evaluate(object value, string arguments = "") { var result = string.Empty; if (value != null) { result = value.ToString(); double amount; if (Double.TryParse(result, out amount)) { if (amount >= 10000) result = "Amount shall be wired directly to..."; } } return result; } } }
Then add to the prinatable setup on amount field: Amount[#AmountMessage#] - the macro will evaluate the amount and return the message if amount is greater or equal to 10000, if not it will return a blank string.
Ryan
Ryan Farley,
I think the custom macro code must be added to a standard package (not assembly) , do you confirm?