CASE: persistent_id

Hi there!

Today we will take a look at the difference between person.persistent_id and person.id.

Both of these methods are useful when we want to access information about a person but there is an important difference.

person.persistent_id is a static variable stored within the people drop and will remain the same no matter which period you are in.

Whereas person.id relates specifically to the reconciliation drop and only the current period that you are in. This means that if you change to a different period the value of person.id will also change.

If you would like to create a collection for a person within the people drop that can be accessed in other periods it is essential that you use persistent_id.


Let’s take a look at an example:

In this block of code, we are using a fori loop on the people drop which allows us to input a person’s name and display their person.id & their person.persistent_id.

{% fori person in period.people %}

<table class="usr-width-100">
  <tbody>
    <tr>
      <td>{{ forloop.index }}.{% input person.name %}</td>
    </tr>
    
    <tr>
      <td>{{ person.id }}</td>
    </tr>
    
    <tr>
      <td>{{ person.persistent_id }}</td>
    </tr>

Next, we want to keep track of the cities that each person is associated to. So we create a collection that is associated to person.id and an input to type the name of the city.

    {% capture person_id %}city_{{ person.id }}{% endcapture %}    
    {% fori city in custom.[person_id] %}
      <tr>
        <td>{% input city.city_name %}</td>
      </tr>  
    {% endfori %}

And here is the collection and input for person.persistent_id

{% capture person_persistent_id %}city_{{ person.persistent_id }}{% endcapture %}
    {% fori city in custom.[person_persistent_id] %}
      <tr>
        <td>{% input city.city_name %}</td>
      </tr>  
    {% endfori %}

  </tbody>
</table>

{% endfori %}

Now let's take a look at the output of this code after we have inputted some information:

2021

The first thing that we notice is the person.id & the person.persistent_id are different to one another.

At first glance, the two collections and inputs operate in the exact same way, but there is actually a big difference which becomes clear when we change periods and roll-forward our data:

2022

Now that we have changed periods we can identify a number of differences

  1. The person.id value has changed.
  2. The person.persistent_id remains the same.
  3. Only the city collection data from person.persistent_id is present.

A final point to bear in mind, is that when you roll-forward and copy data, you should not do it from within the template itself. This only gives you access to the ‘TextProperties’ for the template, and not the people drop where the collection is actually stored.

Instead, it should be done from the companies ‘Prepare period’ page where you can select:

  1. The period you wish to copy the data from

  1. The template where the collection exists
    image (5)

  2. ‘Copy key personnel and general period data’

To summarise, person.id only relates to the reconciliation drop of the current period, thus highlighting the importance of using person.persistent_id when you want to create and access information about a person within different periods.

Happy coding!