Skip to content

Adding configuration options to templates

When designing templates, you can build in some configuration options for the apps that use the template. For example, to:

  • Set a hidden or readonly field to a specific value
  • Set a value to be used in conditional logic (as below)

Note: Options are converted to static values when the template is imported into the portal studio app.

In the following example, the template has a Reply button and a Contact History data grid that can be hidden or shown depending on the requirements of the app that embeds the template.

app_settings_eg

Figure: The example that's used in this section

This example template is configured like this:

App Settings

In the template, each option that can be set in the app is added as a key-value pair.

app_settings_eg1

Figure: Example of configuring the template options

  1. On the app toolbar, click designer-cell-icon-edit and then go to the Options tab.
  2. Add two options where Key is the name of a rule set in the template and Value is the allowed settings.
  3. Click to select the value that will be the default for each option.

Display tasks

In the template, there are separate display tasks to show and hide the Reply button and data grid.

app_settings_eg2

Figure: Example of display tasks to hide and show the button and data grid

The display tasks are attached to a rule set.

The rule set

In the template, there is a single rule set, with one rule for the button and another rule for the data grid. Depending on how each option is set in the app, the rule set runs the corresponding display task.

app_settings_eg3

Figure: Example rule set that runs the hide and show display tasks

For example, this is the rule that shows the Reply button:

app_settings_eg4

For each option configured in App Settings, the rule set applies one rule if the app sets the option to true and the other rule if the app sets the option to false:

app_settings_eg5

Figure: Example conditional logic used by the rule set

In the template, the rule set is run when the OnLoad event is invoked.

Important: If the invoked rule set (or the attached action set or display task set) depend on an incoming activation ID then the current configuration of the option cannot be applied when there is no activation ID and the default for the option is used instead. This applies, for example, when the template is used as a home page app or when previewed in the browser.

How this is used in apps that embed the template

In the app, the template is added in the usual way. To set the options to the required values, you edit the component that contains the embedded template:

app_settings_eg6

And then set the template options as required or accept the default:

app_settings_eg7