StevenMMortimer / salesforcer

This R package connects the Salesforce APIs from R using tidy principles.
https://stevenmmortimer.github.io/salesforcer/
Other
81 stars 19 forks source link

sf_query() timeout on queries with more than 260 results #19

Closed rrmn closed 5 years ago

rrmn commented 5 years ago

Maybe I don't understand SOQL well enough, but I tried below query with a limit of 260 and 270 and received the expected results with the former, a time-out with the latter.

Any ideas?

sf_query("SELECT o.Id, o.Owner.Name, o.LeadSource, o.Name, o.AccountId, o.CreatedDate, o.Probability, o.CloseDate, o.StageName, o.OwnerRole__c, Close_Reason__c, Reference_Opportunity__c, CampaignId, Campaign.Name, 
          (SELECT Id, ...,  FROM OpportunityLineItems) 
          FROM Opportunity o 
          WHERE o.OwnerRole__c like 'Sales%' OR o.OwnerRole__c like 'CustomerSuccess'
          LIMIT 260")

works

sf_query("SELECT o.Id, o.Owner.Name, o.LeadSource, o.Name, o.AccountId, o.CreatedDate, o.Probability, o.CloseDate, o.StageName, o.OwnerRole__c, Close_Reason__c, Reference_Opportunity__c, CampaignId, Campaign.Name, 
          (SELECT Id, ...,  FROM OpportunityLineItems) 
          FROM Opportunity o 
          WHERE o.OwnerRole__c like 'Sales%' OR o.OwnerRole__c like 'CustomerSuccess'
          LIMIT 270")

time-out

StevenMMortimer commented 5 years ago

@RomanAbashin Queries are tough to debug for me because I don't have access to your org or your data to see what the root cause of the issue is. There are a few routes to go, all of which depend on the level of data you are allowed to share with me or publically:

  1. You look at the code that's behind sf_query() and run it step-by-step and let me know at which point it is failing.
  2. You take some screenshots and post here or email to me (reportmort@gmail.com) the data or artifacts from running other functions that might point out why it's not completing. For example:
    • What do you see when you set verbose=TRUE argument?
    • What happens if you change the page_size argument?
    • What happens if you try using the "SOAP" API type?
    • What happens if you change your query? I can't tell exactly what fields you're pulling, but it may be possible to write the query in a simpler way. Some objects don't require a subquery to reference related items like you're doing with (SELECT Id, ..., FROM OpportunityLineItems). I recommend using Salesforce's Workbench tool to see how it builds out queries.
  3. You invite me to your organization so I can access the data to test with it.

One last thing, I'm not sure what you mean by "timeout" (e.g. no response after 5 seconds, 60 seconds, 60 minutes, etc.) and whether or not that's an issue on the Salesforce side or the salesforcer package.

rrmn commented 5 years ago

@StevenMMortimer Thanks for the reply. By timeout, I meant no response after 5 minutes of waiting. The same query runs with RForcecom without any problems. I'll dig into the function, though. Thank you!

StevenMMortimer commented 5 years ago

@RomanAbashin Please let me know if you're still having issues. Otherwise, I'll close this issue since I can't reproduce or help. Thanks.

StevenMMortimer commented 4 years ago

@RomanAbashin Apologize for the extremely long delay. This is well overdue, but finally got to the heart of the issue with some help from #54. This fix is already on GitHub and will be included in the new release of the package (v0.2.0) coming in the next few days. Upgrade your version of {salesforcer} package to (>= 0.1.4.9999) and you should be good to go. Thanks for your patience.