RangerMSP Business Automation for successful ITs


Go Back   RangerMSP Forums > RangerMSP Software Discussion Forum (CCRM)

Thread Tools Search this Thread
 
March 10th, 2020, 11:54 AM
CraigYellick
 
Posts: 53
I'm using the .Net API for what I have to think is a very common use-case: for a specific account, fetch all secondary contacts. Here's the code.

Dim qry As New ObjectQuery(Of CommitCRM.Account)(LinkEnum.linkOR, maxUserCount)

qry.AddCriteria(CommitCRM.Account.Fields.AccountMa nager, OperatorEnum.opEqual, AccountRecID)

Dim results As List(Of CommitCRM.Account) = qry.FetchObjects()

For an account with three contacts this query runs in a second or two. That's acceptable. An account with 75 contacts is taking around 30 seconds. At 190 contacts it takes almost three minutes.

Any ideas?

-- Craig
 
March 10th, 2020, 12:59 PM
Support Team
 
Posts: 7,514
Thank you for asking.

From a quick look at your code it seems like all data fields are fetched, and this might mean many fields that you do not need.

By default Accounts are fetched with their entire details behind the scenes, it would be certainly be faster if you load only the needed fields. For example, here is how you could fetch the accounts for only two field:

lstAccounts = objQuery.FetchObjects(RangerMSP.Account.Fields.Acc ountREC_ID.Key + "," + RangerMSP.Account.Fields.FileAs.Key)

Basically you need to pass a comma separated string with the field names that you need access to. Please give it a try and see whether it helps.
 
March 10th, 2020, 01:14 PM
CraigYellick
 
Posts: 53
Thought it would be something like that! I didn't notice that FetchObjects() had that overload option.

The 190 contact case is now down to 10 seconds, that's tolerable.

Thanks so much for the quick response.
Reply





All times are GMT -6. The time now is 01:14 PM.

Archive - Top    

RangerMSP - A PSA software designed for MSPs and IT Services Providers
Forum Software Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.