Person list record counts

When viewing a list of people from the company (i.e. Person tab), the count of the records is wrong. I can tell by looking at the screen and by reading another post that the record count is only counting records where the Person type is NULL. The type is populated in the field PeLi_Type.

From a previous post I found in the community, it appears the count is calculated as follows…

select count(distinct pers_personid) as fcount
from vListPerson WITH (NOLOCK)
WHERE PeLi_CompanyId=[Company ID] and PeLi_Type is null

I am hoping someone can tell me how to adjust the record count so that is calculating the correct number of records. I do not know where the information for the record count is stored in the system.

Thank you for any assistance you can provide!

  • 0

    To link a Person record to a Company, there is a PersonLink record with the peli_type = NULL. Other PersonLink records are created for each type checked in the Person summary screen. So eg if Admin and Sales are both checked there will be three PersonLink records for that person; one with peli_type = NULL and one for each checked type with peli_type = 'Admin' and peli_type = 'Sales' respectively.

    There therefore may be multiple PersonLink records for a single Person if any of the type checkboxes are checked. So if you want to count the number of Person records linked to a Company, it is necessary to count the PersonLink records where peli_type = NULL.

    Have you tried executing the query in SSMS for a Company where the wrong person count is displayed? If it returns the wrong count in SSMS, execute:

    select *

    from vListPerson WITH (NOLOCK)

    WHERE PeLi_CompanyId=[Company ID] and PeLi_Type is null

    if the count is too high, and/or

    select *

    from vListPerson WITH (NOLOCK)

    WHERE PeLi_CompanyId=[Company ID]

    if it is too low, and check out the rows returned to determine why the count is incorrect.

  • 0

    Paul...

    Thank you! Interesting. I did not realize the person_link table worked that way. I also did not realize that a a person could be more than one type.

    If I follow what you are saying, if a person has been assigned a person type, that person will have two records in the person_link table...one record will have a NULL in the peli_type field and the other record for the same person will have a "type" in the peli_type field. Since a person can be more than one type, the system uses the "NULL" record for the count.

    I had run some queries in SSMS and I could see it was only counting the NULLs...but I did not understand why. Now I think I do.

    These records were imported and only one record was populated in the person_link table which is the type record. I think that explains the issue.

    I will see if adding the Null record resolves the issue.

    Thank you for your assistance!

  • 0

    Paul...

    I added the NULL record (for PeLi_type) to the person_link table and my counts are correct now.

    Thank you!