Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected fields are not returned with some API types (warning or message would be helpful) #118

Closed
kmcd39 opened this issue Mar 18, 2022 · 2 comments
Assignees
Labels
question or help Clarification or help may suffice to resolve

Comments

@kmcd39
Copy link

kmcd39 commented Mar 18, 2022

I'm new to working with salesforce, but reporting unexpected behavior where it seems a warning or different behavior should be happening.

When I query all fields for an object in client's salesforce system using salesforcer::sf_query with default api_type, some fields are omitted with no warning. When I try to manually select omitted fields, same result. However, when I switch api_type="BULK 1.0", this works.

A message, warning, or other behavior would have been very helpful for me.

Code example. Given our Contact table, which has fields:
Id, MobilePhone, HomePhone and others:

# omits "HomePhone"
'SELECT FIELDS(ALL) FROM Contact LIMIT 200' %>% salesforcer::sf_query() 

# also omits "HomePhone"
'SELECT id, phone, mobilephone FROM Contact LIMIT 200' %>% salesforcer::sf_query() 

# shows expected behavior: all three columns are returned.
'SELECT id, phone, homephone FROM Contact LIMIT 200' %>%
  salesforcer::sf_query(api_type = 'Bulk 1.0'
                         ,object_name = 'Contact')
@StevenMMortimer
Copy link
Owner

Thanks for flagging @kmcd39. Is it possible that every one of those 200 records has a null value for homephone? If so, then you might have run into the same issue that another user flagged in #78.

In short, the REST or SOAP API will not return the requested column if all values are null in the results, so it can't be parsed. The only way that the sf_query() function would know that the column was requested is if it parsed the query string or checked the object metadata (in the case of using FIELDS(ALL)). I haven't implemented either solution because parsing can be error prone and will make the function slower. My recommendation for now is to use the Bulk APIs (which return all columns requested) or use the SOAP or Rest APIs and check that all columns exist after the results are returned.

If that is not the case, then I can try to investigate further. Happy to help.

@StevenMMortimer StevenMMortimer added bug Unintended behavior that should be corrected question or help Clarification or help may suffice to resolve and removed bug Unintended behavior that should be corrected labels Mar 21, 2022
@StevenMMortimer
Copy link
Owner

@kmcd39 Closing for now. Feel free to re-open if you have more to add on this issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question or help Clarification or help may suffice to resolve
Projects
None yet
Development

No branches or pull requests

2 participants