#398 - Can't use values in Header & Footer in the .docx
Can't use passed values in Header and Footer of the template. - displays as text like "a_name[field_name]"
Can't use passed values in Header and Footer of the template. - displays as text like "a_name[field_name]"
10 years ago
In the header and footer you can not use fields from the dataset of the document. You only can use global variables of Sugar, variables like [onshow.xxx]. For example, to show the global variable of Sugar "current_user", you can put the variable [onshow.current_user.full_name] (this is equivalent to $GLOBALS['current_user']->full_name value). Other example is [onshow.sugar_version]
If you need a variable which is not a Sugar global variable, you can create an event into the calculated fields of your module like the next example:
function BeforeMergeBlock() { $GLOBALS['TemplateCurrentUserName'] = $GLOBALS['current_user']->full_name; }
With this code you can use the variable [onshow.TemplateCurrentUserName] variable into the header or the footer.
We will review the documentation and update it with this information.
10 years ago
Thanks for reply! I asked because i wanted to use Contract's number and published day in the header + internal Word's page numbering option. Will i be able to set these values to function BeforeMergeBlock( ) { } ? May be it will be useful to set array of the values from detailview by default to be able to use them in the Header & Footer...
10 years ago
Yes, you can set these values in BeforeMergeBlock event. Take a look to the "custom/modules/Opportunities/DHA_DocumentTemplatesCalculatedFields.php" file example to create custom calculated fields to modules, and how to use BeforeMergeBlock (take care of the file class name).
"... May be it will be useful to set array of the values from detailview by default ... " Sorry, this cannot be added as new general feature because the component is used too from listview, where we have data from several records.