#600 - Possible to support conditional values
I want to do a mail merge with a word document but the value from sugar may be left blank. So I would like to do something like if [a.fieldname]="" "n/a" [a.fieldname] (word syntax for mail merge.... Is this possible?
10 years ago
Yes, you have two options:
Use calculated fields. See documentation and examples in file custom/modules/Opportunities/DHA_DocumentTemplatesCalculatedFields.php (functions SetCalcFieldsDefs and CalcFields)
Use special variable declaration in templates. Several examples for primary_address_street, in Contacts module: [a.primary_address_street;if [val]='';then 'ADDRESS STREET: n/a'; else 'ADDRESS STREET: [val]'] [a.primary_address_street;if [val]='';then 'n/a'; else [val] ] [a.primary_address_street;if [val]!='';then [val]; else 'n/a']
10 years ago
in the example, I don't see where [val] is defined. Is that defined in the php file, or can you do that in the document?
10 years ago
[val] is not defined, is the variable value within the scope of the statement. You need to write it as is : '[val]'.