by Izertis

Create documents in docx, xlsx (MS Office Word and Excel), odt, ods (LibreOffice and OpenOffice) and pdf format without MS Office or others plugins installed from any module and subpanel using templates.

Includes a 30 day guarantee
Try it Now

By clicking you consent to share your profile with the developer

#600 - Possible to support conditional values

Closed General Question created by ldevin2 8 years ago

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?

  1. dharma member avatar

    Izertis Provider

    8 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']

    • ldevin2 member avatar

      ldevin2

      8 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?

    • dharma member avatar

      Izertis Provider

      8 years ago

      [val] is not defined, is the variable value within the scope of the statement. You need to write it as is : '[val]'.

This case is public. Please leave out any sensitive information such as URLs, passwords, etc.
Saving Comment Saving Comment...
Rating