Technical

The Table Templates add-on replaces the need of building custom templates using WordDocFactory to be able to include images and/or data from subtables in Lime CRM.

Components

Table Templates consists of the following components:

Table and Field Definitions Lime CRM

These tables and fields must be created before you can use the Table Templates add-on. The fields will be created by LIP. If you are not using LIP you will need to create them manually.

Tables used:

Local name Database name
Table Template tommytemplate
Table Template - Table tommytemplate_table
Table Template - Table column tommytemplate_tablecolumn
Table Template - Shape tommytemplate_shape

Table Template

Local Field Name Database Field Name Field Type Length Description
Display name displayname Text 128
Main card tableorigin Text 128
Not based on a main card withouthead Yes/No N/A
Template type templatetype Option N/A See options below
Template from Template Manager templatename Text 128
Name of generated document documentname Text 128 Can contain field codes
Document type documenttypekey Text 256 What type to set on the created document card
Inactive inactive Yes/No N/A
Save as PDF saveaspdf Yes/No N/A
Open when done openwhendone Yes/No N/A
Tables tommytemplate_table Relation (tab) N/A
Shapes tommytemplate_shape Relation (tab) N/A
Options for field tommytemplate.templatetype
Key En Sv Da Fi No
excel Excel Excel Excel Excel Excel
word Word Word Word Word Word

Table Templates - Table

Local Field Name Database Field Name Field Type Length Description
Table Templates tommytemplate Relation (field) N/A
Table index (in template) tableindex Integer N/A
Table name (in template) tablename String 128
Sheet index - Excel (in template) sheetindex Integer N/A
Hide if empty deleteifempty Yes/No N/A
From tab subtableorigin Text 128
Fetch rows sourcetype Option N/A See options below
From filter sourcefilter Text 128
Order by (prio 1) orderby1 Text 128
Ascending/Descending 1 orderby1_order Option N/A See options below, Shared with orderby2_order and orderby3_order
Order by (prio 2) orderby2 Text 128
Ascending/Descending 2 orderby2_order Option N/A See options below, Shared with orderby1_order and orderby3_order
Order by (prio 3) orderby3 Text 128
Ascending/Descending 3 orderby3_order Option N/A See options below, Shared with orderby1_order and orderby2_order
Columns tommytemplate_tablecolumn Relation (tab) N/A
Options for field tommytemplate_table.sourcetype
Key En Sv Da Fi No
filter Filter Urval Filter Filter Filter
selected Selected rows Markerade rader Selected rows Selected rows Selected rows
all All Alla All All All
Options for field (Shared) tommytemplate_table.orderby1_order/.orderby2_order/.orderby3_order
Key En Sv Da Fi No
asc Ascending Stigande
desc Descending Fallande

Table Templates - Table column

Local Field Name Database Field Name Field Type Length Description
Column number columnno Integer N/A
Table tommytemplate_table Relation (field) N/A
Text before value valueprefix Text 128
Field name fieldname Text 128
Text after value valuesuffix Text 128
Sum column sumvalue Yes/No N/A
Image scaling image_scalesetting Option N/A See options below
Max width (if image field) image_maxwidth Integer N/A
Max height (if image field) image_maxheight Integer N/A
Options for field tommytemplate_tablecolumn.image_scalesetting
Key En Sv Da Fi No
scale_none No scaling Ingen skalning
scale_down Only scale down Skala endast ner
scale_up Only scale up Skala endast upp
scale_both Scale up and down Skala upp och ner

Table Templates - Shape

Local Field Name Database Field Name Field Type Length Description
Table Templates tommytemplate Relation (field) N/A
Shape name shapename Text 128
Sheet index - Excel (in template) sheetindex Integer N/A
Source source Option N/A See options below
Hide if empty deleteifempty Yes/No N/A
From tab subtableorigin Text 128
From filter sourcefilter Text 128
Field name fieldname Text 128
Options for field tommytemplate_shape.source
Key En Sv Da Fi No
field Field Fält
filter First in filter Första i urval First in filter First in filter First in filter

Lime Bootstrap App

The app have two functions:

  • Managing and configuring a template
  • Use a template from an ActionPad

Manage template

It is a Lime Bootstrap form for configuring a template, it opens a modal Window.

See How it Works for more details and screen shots.

Use template

It shows a drop-down list of all available templates for the card you're on.

Localizations

All localizations are stored in the localize table in Lime CRM.

Actionpads

The newly created table tommytemplate has an Actionpad.

VBA

The VBA modules are the engine behind Table Templates. It is this code that populates the Lime CRM Word or Excel templates into Lime CRM documents filled with relevant data.

  • AO_TableTemplates.bas
  • AO_TableTemplatesColumnData.cls
  • AO_TableTemplatesHandler.cls
  • AO_TableTemplatesHandlerExcel.cls
  • AO_TableTemplatesHandlerWord.cls
  • AO_TableTemplatesTableData.cls
  • AO_TableTemplatesTemplateData.cls

Custom workflows

Table Template have it's default app that can be used to show all available templates dynamically but sometimes you want to use Templates as part of a custom workflow. Therefore it have some functions that you can use in your own flows.

AO_TableTemplates.TryToCreateTemplateFromInspectorByName

Sub TryToCreateTemplateFromInspectorByName(
    ByVal sTommyTemplateName As String,
    Optional ByVal sMailTemplateName As String = ""
)

Used to create a given template (using Name) with an inspector as a source. You have an Optional argument sMailTemplateName if you pass a E-mail Template name it will automatically open the E-mail template and attach the created Table Template to that E-mail.

AO_TableTemplates.TryToCreateTemplateFromExplorer

Function TryToCreateTemplateFromExplorer(
    ByVal lngIdTommyTemplate As Long,
    Optional ByRef oCreatedDocumentsPool As LDE.Pool = Nothing
) As Boolean

Used to create a given template (using ID) with an explorer as a source. it returns a Boolean that is True if the template is successfully created, otherwise False. You have an Optional argument oCreatedDocumentsPool where you can get all created document ids if you would like to continue your custom flow.

AO_TableTemplates.TryToCreateTemplateFromInspector

Function TryToCreateTemplateFromInspector(
    ByVal lngIdTommyTemplate As Long,
    ByVal sInspectorId As String,
    Optional ByRef oCreatedDocumentsPool As LDE.Pool = Nothing
) As Boolean

Used to create a given template (using ID) with an inspector as a source. it returns a Boolean that is True if the template is successfully created, otherwise False. You have an Optional argument oCreatedDocumentsPool where you can get the created document id if you would like to continue your custom flow.

AO_TableTemplates.GetAvailableTemplates

Function GetAvailableTemplates(
    Optional ByVal sInspectorId As String = ""
) As String

Returns all available templates for the given context in XML If you send in an InspectorId you will get all templates available for that card and all of it's explorers. If you don't send an InspectorId it will get all templates availale for explorers in the main view. You can filter your templates by using the attributes useOnExplorer and useOnInspector.

Can be used as an data source in LBS like this:

{
    "type": "xml",
    "source": "AO_TableTemplates.GetAvailableTemplates",
    "alias": "templates",
    "PassInspectorParam": true
}

You get the data in the following format:

<templates>
    <tommytemplate
        idtommytemplate="1004"
        createduser="2901"
        createdtime="2019-10-18 08:50:15"
        timestamp="2019-10-18 08:52:26"
        descriptive="Participant list"
        updateduser="2901"
        displayname="Participant list"
        tableorigin="campaign"
        withouthead="0"
        templatetype="285901"
        templatename="Participant List"
        documentname="Deltagarlista - %%name%%"
        documenttypekey="other"
        inactive="0"
        saveaspdf="0"
        openwhendone="0"
        useOnExplorer="campaign"
        useOnInspector="campaign">
    </tommytemplate>
    ...
</templates>