Pseudo-relations

Pseudo-relations are user-created links between data - you create a relation where there was none before, hence the name.

Concept

Pseudo-fields are a way of linking data structures together. Both data structures have a unique identifying field that binds them together. Pseudo-relations can be done between 2 separate data sets, but you can also link data from the same data set.

In the following example, every agent can have one or more tickets assigned to them, and one ticket can be assigned to multiple agents. We have 2 data sets: agents and tickets. Agents holds all the necessary data about the agents, while tickets contains all the info about the ticket:

The linking field here is ID under ticket. The advantage of structuring our data sets this way is that there is no redundant information included: every agent simply holds a reference to a ticket, instead of all the ticket's data. This is a trivial gain in the example we use, but it can make a significant difference when working with large amounts of data.

Setting up pseudo-relations

Creating a pseudo-relation

To create a pseudo-relation, follow these steps:

1. In the data set tab of the pane, select the parent element of the new pseudo-relation. The pseudo-relation will become a child element of this element:

  • The Display name field is what you're going to call the pseudo-relation.

  • The Parent field is the selected field when you clicked the new pseudo-relation button. You can change that here, if needed.
  • The From field is the element that holds the reference to the data (in this case: agents/agent/tickets/ticket).
  • The Field field is the field in the From element that links the two together (in this case: ID)
  • The To field is the element that holds the full data (in this case: tickets/ticket)
  • The Field field is the field in the To element that links the two together (in this case: ID).
2. Select OK to confirm the settings. You can change them afterwards if you like (but keep in mind that any already mapped fields may no longer work if your changes are structural).

Now, you'll see that your data set has expanded:

Next to ticket (under agents/agent/tickets), there is now Ticket info, which holds all the fields of tickets/ticket.

Editing a pseudo-relation

To edit a pseudo-relation, select it and select the blue  pencil:

This will bring up the window that you got when you created the pseudo-relation. Keep in mind that making structural changes may render mappings to be invalid (since they reference something that no longer exists)

Removing a pseudo-relation

To remove a pseudo-relation, select it and select the red X:

Using pseudo-relations

Once the relation is in place, you can use it to display the full data instead of just the reference. In our case, displaying just the reference would make for pretty empty tables:

It's a very simple template so far:

Let's expand the tickets table to loop over Ticket info (our new pseudo-relation). Like this:

We put the TICKETS FOR NAME outside of the table and put 3 columns in the table (and mapped the fields in there).

This looks much better. Remember to loop over the pseudo-relation and map the fields from inside the pseudo-relation:

Once the pseudo-relation is set up, that's pretty much the only difference: instead of looping over the original ticket, you now loop over Ticket info, and map the new fields that come with the pseudo-relation.

Of course, looping is only necessary if multiples are possible. It could very well be that every agent can only hold one ticket (in our example), so in that case you would not loop, but simply map the fields under Ticket info.

Example

You can try this example out for yourself if you have the Template Builder and a connection to a Smart Flows server. Download the .docx file below:

PR_Example.docx

Open this file and Word will open it with the Template Builder. Make a connection to your Smart Flows server, and you can then generate a preview that looks like the examples used above.

This file includes the following:

  • PR Example (template)
  • PR Agents (data set)
    • PR Agents local (sample)
  • PR Tickets (data set)
    • PR Tickets local (sample)