We’ve developed some resources to help you work effectively from home during COVID-19 Click to learn more

associateAgent.GetAssociatesByGroup­(iGroupId, iType)

Hi there,

If I do this:

int iGroupId = 2; 
SuperOffice.Services80.AssociateAgent associateAgent = new SuperOffice.Services80.AssociateAgent();
int iType = 0; //0 is the type for InternalAssociate in the Associate Table
SuperOffice.Services80.Associate[] assocs = associateAgent.GetAssociatesByGroup(iGroupId, iType);

I do not get any associates returned

If I do this:

int iGroupId = 2;
SuperOffice.Services80.AssociateAgent associateAgent = new SuperOffice.Services80.AssociateAgent();
int iType = (int)SuperOffice.Services80.UserType.InternalAssociate; //iType will have the value of 1
SuperOffice.Services80.Associate[] assocs = associateAgent.GetAssociatesByGroup(iGroupId, iType);

I get all of the Resources instead (even though the Resources usergroup is 0)

 

If I do this:

int iGroupId = 2; //oUserGroups[i].Id
SuperOffice.Services80.AssociateAgent associateAgent = new SuperOffice.Services80.AssociateAgent();
int iType = (int)SuperOffice.Services80.UserType.ResourceAssociate; //iType will have the value of 2
SuperOffice.Services80.Associate[] assocs = associateAgent.GetAssociatesByGroup(iGroupId, iType);

Then I get all Internal Associates belonging to UserGroup 2

 

Is there a bug in there somewhere or am I using the functions incorrectly?

 

Cheers James

RE: associateAgent.GetAssociatesByGroup­(iGroupId, iType)

Hello,

I have same behavior in the actually SOD Tenant of us.

calling

using (AssociateAgent agent = new AssociateAgent())
{
   Associate[] associates = agent.GetAssociatesByGroup(2, (int)SuperOffice.Services88.UserType.ResourceAssociate);
}

and I get active users who have GroupId=2 in the primaty or secondary group.

The call with InternalAssociate returns no resulting associates.

Could anybody please explain this behavior?
Maybe are here the parameters switched?

Thank you in advance!

Av: Andrey Stupak 12. jul 2020

RE: associateAgent.GetAssociatesByGroup­(iGroupId, iType)

The incorrect assumption here is that type refers to a associate type. The documentation rightly defines the type as DiaryGroupType.

The recommended way to get all associates of one of more groupid is to use the InternalUsers archive provider. 

DO NOT USE TYPES IN VERSIONED NAMESPACES!
Instead of SuperOffice.Services88.WHATEVER
Use: SuperOffice.CRM.Services.WHATEVER

Hope this helps!

Av: Tony Yates 13. jul 2020

RE: associateAgent.GetAssociatesByGroup­(iGroupId, iType)

Thank you Tony, that helps a lot!

Actually I can't find in the InternalUsers Achive Provider an option to get Users via both primary or secondary group (I miss the secondary group). Have I overlooked something in the documentation?

Cheers, Andrey

Av: Andrey Stupak 13. jul 2020

RE: associateAgent.GetAssociatesByGroup­(iGroupId, iType)

Hi Andrey,

You have a couple different options but I think the best way to get both primary and secondary in one query is to use the dynamic archive provider and fetch all groups for all associates.

Here I use the REST API, but I'm confident you know how to transform the select fields into select columns, the filter into ArchiveRestrictionInfo, and the Order info if necessary.

/api/v1/archive/dynamic?$select=usergrouplink.assoc_id,usergrouplink.assoc_id.name,usergrouplink.UserGroup_id,usergrouplink.assoc_id.group_idx&$filter=usergrouplink.assoc_id.type=0&$orderby=usergrouplink.assoc_id

Hope this helps!

Av: Tony Yates 13. jul 2020