In many organizations there are goals that rely on more than one individual to be successfully achieved. A contributor has a direct impact on the results or completion of an OKR. Below you will find a complete guide on how to visualize the contributors in an insight on Objective level.

1. Create a custom field

First step is to create the custom field from your settings menu. Navigate to Settings -> Custom fields and then add a new custom field.

Here is an example of how the custom field could look like:

You can also refer to this video for additional information on how to create a contributor custom field.

2. Add it to an existing insight

Download a Gtmhub insight from the Marketplace

When you have your custom field ready, navigate to the Marketplace -> Insights -> Gtmhub and select OKRs Progress List v.2 (just as an example) insight. Add it to a new or an already existing insightboard and go to this board in Gtmhub.

Add the contributor field in the insight

From the three dotted selector on top choose Re-arrange (or simply press E on your keyboard) and edit the insight from the middle button (</>). Then you will see the two separate windows - HTML & SQL parts.

First you need to add the following snippet in the SELECT in the SQL part (the right window):

CASE WHEN gtmhubgoals.customfields <> ''
THEN string_to_array(BTRIM(regexp_replace(gtmhubgoals.customfields::json ->> 'contributor', '[^\w]+', ',', 'g'), ','), ',')
END AS contributor

After that to visualize this data there are two code snippets that you need in the HTML section:

  • add an additional header in the table

<th style="font-size: 14px; font-weight: bold">Contributor</th>
  • add an additional table data cell <td>

<div ng-if="!objectives.contributor || objectives.contributor == ''" class="badge badge-warning">No Contributor</div>
<div ng-if="objectives.contributor != '[]'" ng-repeat="t in objectives.contributor track by $index">
<assignee id="{{t}}"></assignee>

Here is how the insight should look like:

This video will guide you step by step.

3. Create a new insight

If you would like to see an overview of the objectives with their owners, progress and contributors, here is the code you need to use to create this insight.

First go to an insightboard and select from the three dotted menu on top - Create an insight.

In the HTML part (the left side when you open the edit insight option) copy-paste the following snippet:

.merge-above {
border-top: 0 !important;
opacity: 0 !important;

.merge-below {
border-bottom: 0 !important;
<div class="title-xlg">{{insight.title}} </div>
<div class="table-scroll" ng-if="data && data.objective_id">
<table class="table mt-2" ng-init="objectives = (data.default.length > 0) ? data.default : [data];" style= "border-collapse: collapse !important">
<th style="font-size: 14px; font-weight: bold" ng-click="orderKey = 'objective_name'; reverse = !reverse;">Objective name</th>
<th style="font-size: 14px; font-weight: bold" ng-click="orderKey = 'objective_owner'; reverse = !reverse;">Objective Owner</th>
<th style="font-size: 14px; font-weight: bold" ng-click="orderKey = 'objective_progress'; reverse = !reverse;">Objective Progress</th>
<th style="font-size: 14px; font-weight: bold" ng-click="orderKey = 'contributor'; reverse = !reverse;">Contributor</th>
<tr ng-repeat="contributors in objectives | orderBy : orderKey : reverse" style="pading: 30px;">
<img src="/dist/img/icons/objective.svg"/>
<a class="link-accent dark" ui-sref="._singleGoal.goal._metric.metric({id: contributors.objective_id, metricId: contributors.objective_id})">{{ contributors.objective_name }}</a>
<assignee id="{{contributors.objective_owner}}"></assignee> <action id="{{contributors.objective_owner}}" type="send-email" ></action>
<td>{{contributors.objective_progress| number:2}} %</td>
<div ng-if="!contributors.contributor || contributors.contributor == ''" class="badge badge-warning">No Contributor</div>
<div ng-if="contributors.contributor != '[]'" ng-repeat="t in contributors.contributor track by $index">
<assignee id="{{t}}"></assignee>

In the SQL part (the right window in the edit option) add this code snippet:

SELECT AS objective_id, AS objective_name,
gtmhubgoals.ownerid AS objective_owner,
100*gtmhubgoals.attainment AS objective_progress,
CASE WHEN gtmhubgoals.customfields <> ''
THEN string_to_array(BTRIM(regexp_replace(gtmhubgoals.customfields::json ->> 'contributor', '[^\w]+', ',', 'g'), ','), ',')
END AS contributor
FROM gtmhubgoals
CASE WHEN '%%session%%' <> ''
THEN (gtmhubgoals.sessionid IN (SELECT(UNNEST(string_to_array('%%session%%', ',')))))
ELSE true
AND CASE WHEN '%%team%%' <> ''
THEN (gtmhubgoals.ownerid in (SELECT user_id FROM gtmhubteammembers
WHERE team_id in (SELECT(UNNEST(string_to_array('%%team%%', ',')))))
OR (gtmhubgoals.ownerid in (SELECT(UNNEST(string_to_array('%%team%%', ',')))))
OR (gtmhubgoals.ownerid in (SELECT manager FROM gtmhubteams
WHERE id IN (SELECT(UNNEST(string_to_array('%%team%%', ',')))))))
ELSE true

The code will create an insight that will look like this:

If there are contributors on any objective, they will be displayed separately with their avatar, first and last name. In case there is no contributor, the badge NO CONTRIBUTOR in yellow will be visible. The insight also contains team and session filters, which are default insightboard parameters and you don't need to create them additionally.

Did this answer your question?