Mindville Insight

Since v 2.4

TemplateMe! allows you to obtain Insight custom field values and use it in the notification templates.

Integrations test were made for Insight versions 8.3.X

 

How to add an Insight custom field in a template?

Let’s begin with this issue with these two insight custom fields (Operating system and CPU):

 

If you want just to use the label value of these custom fields you can directly use the usual $customfield_xxxxx tag in a template. For example:

<p>CPU: $!customfield_10202</p> <p>Operating system: $!customfield_10203</p>

Will render this email:

Easy peasy!

But let’s say I would like to also get the number of cores of the CPU:

We will need to access the Cores per processor attribute and we can do it using the $insightcf tag in the template:

<p>CPU: $!customfield_10202</p> <p>Number of cores: $!nsightcf.getObject("customfield_10202",133).getValue()</p> <p>Operating system: $!customfield_10203</p>

for the $insightcf we need two values: The first one is the customfield id – in our example, CPU is the customfield_10202. The second one if the attribute id value. We could get this value from the attributes page of the object type we want to use:

In the case of the CPU’s Cores Per Processor the attribute ID is 133.

The previous template will be rendered this way:

Linked objects

In the case the attribute you want to obtain is actually a link to another Insight object you have to proceed as follow:

Let’s say for the sake of the example that our CPU has a license attribute that directs to another Insight object:

We want to get the license name and also the license expiration date in our email template:

We modify our template like this:

<p>CPU: $!customfield_10202</p> <p>Number of cores: $!insightcf.getObject("customfield_10202",133).getValue()</p> #set ($related_lincese = $!insightcf.getObject("customfield_10202",193)) <p>CPU License: $!insightcf.getRelatedObjectLabel($related_lincese)</p> <p>CPU License end date: $!insightcf.getRelatedObjectAttribute($related_lincese,148).getValue()</p> <p>Operating system: $!customfield_10203</p>

The key parts are these ones:

First of all we want to isolate the license and we do it in this line

#set ($related_lincese = $!insightcf.getObject("customfield_10202",193))

We have the licensed assigned to the $related_license tag.

Now we want the label of the license and do it by calling this method:

$!insightcf.getRelatedObjectLabel($related_lincese)

Also we can access the license attributes. Since the end date is the attribute 148 (you can get this info in the attribute view of the object type), we use this code to get that value:

<p>CPU License end date: $!insightcf.getRelatedObjectAttribute($related_lincese,148).getValue()</p>

The previous template will render this way:

An attribute is a list of insight objects

In all the previous examples we have seen single values. But your Insight object could have a list of values in an attribute.

Let’s say our CPU is related somewhat to some Operating systems:

We would like to print that in our template:

As we did before we want to isolate the value of the attribute SO (id 177)

#set ($sos = $insightcf.getObjects("customfield_10202",177))

Please mind the s in getObjects as we are retrieving potencially multiples values.

Once we have these values we just print their label:

This will render this email:

If instead of related objects they were just simple attributes, the code would be like this:

The rendered email will be this:

If you have any question, let us know.