Countif records match in another Creator app

Countif records match in another Creator app

I have a series of three reports and need to count now many records in each match a central list. Two of the reports are in AppOne - one is in AppTwo
The first part is ok - this code will count every document and reference that match the ID
  1. for each  varRecord in Services[ID != 0]
  2. {
  3.     varRecord.service_document_count=Documents[documents_lookupservices == varRecord.ID].count(documents_lookupservices);
  4.     varRecord.service_references_count=References[references_lookupservices == varRecord.ID].count(references_lookupservices);
  5. }

I also wish to do the same with another app. I have created a function to return a list of all of the ServiceIDs from this app.

The Service field is a lookup from AppOne so I know that the IDs will match across the apps

  1. list AppTwo.GetProcessCount()
  2. {
  3.     varAppTwoRecords = Process[ID != 0].ID.getAll();
  4.     return varAppTwoRecords;
  5. }
At the moment I only have 5 records in the AppTwo.Process report so this function gives me the result of 5 IDs - you will see that one is duplicated which means there are 2 Processes for that Service
72570000002497856
72570000003234200
72570000003390602
72570000003234200
72570000003488126

How do I add this to the above code ?
I know the below is incorrect ... but it's essentially what I am trying to do.

varRecord.service_process_count=AppTwo[Process[process_lookupservices == varRecord.ID]].count(process_lookupservices);