Using KCode

Blank 10/7/2020 09:36 - 10/7/2020 09:36
Editing Content Fundamentals

KCode is a powerful feature that lets you display text content from queries, using hierarchical field navigation.

When using KCode, it is important to understand context.

  • If you want to display a user's personal information on the website dashboard when they log in, for example their name, the context for the site content comes from the current user
  • If you are sending an email as part of a journey, the context for the email content comes from the journey lead.

Context informs where the KCode comes from and the path the code needs to follow.

We will step through some examples of hierarchical KCode below. These examples use a typical organisational hierarchy, with program participants, sales territories, and sales reps in those territories.

Learn more about organisational hierarchy here

We will be logging in as John Peters, a participant in Carphone Warehouse California.

Displaying a participant's name

To start with we will use KCode to show a participant's name on the dashboard when they log in.

1 In KEditor, click the KCode icon to open the KCode modal.

 

2 As we want to display information about the user from their profile, we need to start by selecting Current user.

 

3 Then we can select the information from their profile that we want to display, which in this case will be their First name.

 

4 Click OK to save the KCode.

 

5 Save the page in KEditor.

 

6 Log in as a user to view the KCode.

 

Displaying a participant's company

Now we'll update the dashboard to display the name of the company the participant belongs to.

The KCode will need to find the membership linking the participant to their organisation, and display the name of that organisation.

1 This KCode will still start with the Current user, then we want to look at all their Primary memberships, select the First membership, find the Membership organisation of that membership, and display the Full name of that organisation.

This KCode will look like the below.

2 Log in as a user to view the KCode.

 

Displaying a participant's sales rep

Next we'll add the sales rep of the participant's organisation, so they know who their point of contact is.

The KCode will build on the previous example to find details of the parent organisation, which is the sales territory related to the organisation.

1 This KCode will still start with the Current user, then their Primary memberships, the First membership, and the Membership organisation, but then we will select the Parent organisation, and look at the parent organisation's Primary memberships, the First membership, the Membership organisation, the Membership Profile, then the Full Name of the profile.

This KCode will look like the below.

 

2 Log in as a user to view the KCode.

 

3 If we view the California territory organisation page in the admin site, we can see that California is the parent organisation of Carphone Warehouse California, and that Mark Smith is a member of the California territory, which is why the KCode displays Mark Smith.

You could extend on this to show sales rep details, e.g. a contact phone number and email.

 

Displaying a participant's points

Next we'll add the points balance for a participant.

1 This KCode will still start with the Current user, then their Points account in the relevant points bucket, then the Points balance.

This KCode will look like the below.

 

2 Log in as a user to view the KCode.

 

3 We can customise the KCode further to display the points balance as an integer rather than displaying decimal points by selecting To Integer at the end of the KCode.

 

4 When we log in and view the KCode the number will display with no decimals.

 

The below video will step you through using KCode to display these details.