Code: Select all
#if (${store.CustomFields.Find(cField => cField.FieldName == fieldName).FieldValue} == "true")
Yes
#else
No
#end
Error generating email messages for template 'Customer Order Notification' having subject 'Confirmation - Order Number $order.OrderNumber'.
Exception: Encountered "= >" at line 96, column 39. Was expecting one of: "," ... ")" ... ... ... "[" ... "true" ... "false" ... ... "{" ... "," ... Stack Trace: at NVelocity.App.VelocityEngine.Evaluate(IContext context, TextWriter writer, String logTag, TextReader reader) at CommerceBuilder.Messaging.NVelocityEngine.Process(Hashtable parameters, String template) at CommerceBuilder.Messaging.EmailTemplate.GenerateMailMessages() at CommerceBuilder.Messaging.EmailTemplate.Send(Boolean async) Inner Exception: Encountered "= >" at line 96, column 39. Was expecting one of: "," ... ")" ... ... ... "[" ... "true" ... "false" ... ... "{" ... "," ... Inner Exception Stack Trace: at NVelocity.Runtime.Parser.Parser.Parse(TextReader reader, String templateName) at NVelocity.Runtime.RuntimeInstance.Parse(TextReader reader, String templateName, Boolean dumpNamespace) at NVelocity.Runtime.RuntimeInstance.Parse(TextReader reader, String templateName) at NVelocity.App.VelocityEngine.Evaluate(IContext context, TextWriter writer, String logTag, TextReader reader)
I don't want to use a #foreach ($oneField in $store.CustomFields) loop with an #if statement inside, because as the number of store custom fields grows it will take longer and longer to evaluate. (Actually, the Find() method I'm trying would probably take longer and longer too, but I wasn't sure what else to try).
It doesn't seem like I can use the CustomFieldRepository class in the email template either.
How can I add a store custom field to an email template without it taking order(N) to evaluate? I have the source code, if that helps. Any pointers about where to look in the source code and how to include a parameter to allow access to the CustomFieldRepository when processing email templates?