Sub Entity Mailmerge

Root > 3. Customisation

This it may shed some light on the subject as it pulls data from the activities table, in this example we pull fields from the activity table into an Email letter to confirm the details of an appointment.

 <#displayname value="Email Activity">
<#Editor value=yes>
<#html value="activity.htm">

Dear <#Field field=firstname>,


<#subentity1 debug stable=wce_activity orderby="createtime desc">

                <#Field field=sdate format=date> For a <#Field field=subject> Start time is: <#Field field=stime format=time> and the End time is  <#Field field=End_Time> Teacher: <#Field field=SCHEDULEFOR>

                <br /><br />


More details can be found about subentities here

WiredContact Subentity Sections
  The WiredContact Subentity section is a special section that is used in the same way on a number of different templates. It allows you to easily customize the fields shown in a record from a subentity table for the following functions:
  • Letter templates
  • Email templates
  • subentitylist
  • subentity
  • Lookup (details)
  • Lead
  • SimpleReports
The Subentity Section requires parameters that tell the application engine what table you want to show, and other attributes of how you want to display the data. The subentity section includes four section types: Pre/Main/Post and Empty. The Empty is a special section that (optionally) displays different information if the subentitylist is empty.


The subentity sections are shown in order replacing the <#showsubentity> tag.




The main subentity section tag includes the start phrase (subentity) and the name of the specific subentity section that you are describing. Subentities are shown in order of their names - unless you specify a specific name in the <#showsubentity tag. The Pre/Post and Empty subentity sections will include the subentity name.




For example, if you have a single subentity that you wanted to show, and you don't care what the name is, you might name it "1" - and the section start/stop phrases in this case would look like:




Start main <#subentity1...>
Stop main <#/subentity1>




Start Pre <#presubentity1>
Stop Pre <#/presubentity1>




Start Post <#postsubentity1>
Stop Post <#/postsubentity1>




Start Empty <#emptysubentity1>
Stop Empty <#/emptysubentity1>




Start Summary <#summarysubentity1>
Stop Summary <#/summarysubentity1>




If your table has a child table defined in the table defaults:
Start main child <#subentitychild1>
Start Pre child <#presubentitychild1>
Start Post child <#postsubentitychild1>
Stop main child <#/subentitychild1>
Stop Pre child <#/presubentitychild1>
Stop Post child <#postsubentitychild1>




Subentity Section Parameters:
The main start phrase for a subentity section includes parameters to indicate what to display:




  • stable: the subentity table
    The attributes from the table defaults (Admin...Site Settings...Table Defaults) will describe many of the table attributes. The remainder of the parameters may be used to override the table defaults.
  • OrderBy: Change the order of the records shown, using a standard SQL order clause (leaving out the "Order By" key words):
    orderby="htype, recordedtime desc"
  • Limits: Change which records to show by using a standard SQL where clause (leaving out the "Where" key words):
    limits="(htype = 'Note') and (recordedtime > '20120318')"
  • count: the number of records to display
  • MinCount: the minimum number of records to display - if the result set of the data doesn't have enough records, blank records will be used to fill out the number of records needed.
  • TableType: Use Subentity, SimpleSubentity or Entity to override the table type defined in the table defaults. For example, you can change wce_contact to a simplesubentity using the Company field as the link field to show contact records with the same company value.
  • LinkTable: Link table for subentity table. The default link table is wce_linkto.
  • LinkID: Field to use as the linkid field to link a simplesubentity to the parent table.
  • EntityIDField: Field to use as the ID Field (entityid field) to link a simplesubentity to the entity table.
  • SQL: Use a standard SQL statement to display data. This will override limits, orderby, linkid, linktable, etc.
  • summaryat: The field in the table to use to show summary details - summary is shown when field value changes - this should be a field that is in the sort order.
  • Debug: use this parameter to put extensive debug information into the WiredContact Errors.log file for debugging purposes
  • AJAX: adds the reloadajaxsubentity[name]() javascript function that can be called to refresh the subentity section without reloading the page. If you want to be able to sort subentity sections, use the "ajax" parameter and add "sortable" to the <#Label... tag in the PreSubtentity section. Use the "ajax" parameter to make deleting from the subentity section easier when using the <#Delete...> tag in the subentity sections. See more about AjaxSubentity List.




Passing Parameters
Use the following tags inside the <#Subentity[name] tag to further define the results that are displayed:




  • <#params name=[parametername]> - pass parameters from the initial function call. Useful for Limits and SQL parameters.
  • <#date - show today's date, use offset=x to move forward/back x days, format=sql to format the date string to it's sql formatting (for the SQL/Limits parameters)
  • <#field - parent field data




Showing Subentity Sections
Place the <#showsubentity> tag in the template where you want the Subentity Section to show.

<#showsubentity> tag parameters: Use the Name=[name] parameter to show a specific subentity instead of all defined subentities in a template. For example, to show the subentity "1" as described above, you would use: <#showsubentity name=1>. If you leave out the name parameter, all subentity sections defined in the template will be shown in alphabetical order based on name.




You may also use a Test="boolean phrase" parameter for the <#showsubentity... tag - for example, if you use
test="Customer=<#field field=IDStatus>"
the subentity section will only show if the parent IDStatus field equals Customer. To see what test is being evaluated, use the Debug parameter before the test parameter.




Pre Sections
The pre sections utilizes <#Label...> tags to display the labels at the beginnig of the section. This section would also include any <table...>, <span...>, <div...> structures used to format the data in the <#detail section.




Post/Summary Sections
The post/summary section utilizes <#Count...> and <#Sum...> tags to display summary information. This section would also include any necessary tags to close the html structures used to format the data in the <#predetail section.




Add Feedback