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

better support within Swiftly Salesforce for multi-record inserts #102

Open
perbrondum opened this issue Jan 20, 2019 · 11 comments
Open

better support within Swiftly Salesforce for multi-record inserts #102

perbrondum opened this issue Jan 20, 2019 · 11 comments
Assignees

Comments

@perbrondum
Copy link

See #54.

@mike4aday
Copy link
Owner

@perbrondum can you provide more details? Are you looking for 'direct' support of the composite API insert capability? https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobjects_collections_create.htm

@mike4aday mike4aday self-assigned this Jan 22, 2019
@perbrondum
Copy link
Author

perbrondum commented Jan 23, 2019 via email

@mike4aday
Copy link
Owner

@perbrondum the new-ish Composite API does just that - inserts up to 200 records, and has an "all or nothing" option. I can add a method to Swiftly Salesforce that uses the Composite API, but AFAIK it does "cost" 1 API call per object inserted. That is, even though it's a single HTTP request, if the request to the Composite API post insert method contains 'n' sub request records, then your API allotment is reduced by 'n.'

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobjects_collections_create.htm

@ghost
Copy link

ghost commented Jan 25, 2019 via email

@mike4aday
Copy link
Owner

@perbrondum will do! Thanks

@ghost
Copy link

ghost commented Jan 25, 2019 via email

@mike4aday
Copy link
Owner

Hi @perbrondum - which recent reply are you referring to? Can you link to it? From your description, both queries, with and without the "group by" clause, would cost 1 API call.

The cost of an API call refers to the allocations detailed here. Each call to the standard REST API reduces the available API count by 1.

The newer composite API essentially allows you to make a single HTTP request and pass a list of up to 200 records that will be inserted, updated, etc. Salesforce will take care of iterating through the list, but still "charges" 1 API call per record in that list. You get improved performance, however, because your mobile client doesn't have to open an HTTP connection for each record.

As you noted, you could create your open Apex method, expose it as a REST endpoint, and call it with Swiftly Salesforce's apex method. Even if that Apex method operates on 'n' records, you're still only charged 1 API call.

BUT whenever possible you should favor the out-of-box Salesforce REST API endpoints over custom Apex REST endpoints. Salesforce takes care of optimizing and testing the out-of-box endpoints. Your Apex methods, however, are subject to all the platform governor limits, e.g. heap size limit, number of query results, query time, etc. You have to implement your own result set pagination, and test for unexpectedly high data volumes, etc.

@ghost
Copy link

ghost commented Jan 29, 2019 via email

@mike4aday
Copy link
Owner

@pbrondum that refers to a different limit: the total number of query rows. The API limit, however, refers to the number of calls into the Salesforce platform from an external client. An external client running a query via the REST API would be subject to both limits - on the number of API calls within a rolling 24 hour period, and the total number of query rows.

@perbrondum
Copy link
Author

Thanks. I'm going to have to read up on this. Per

@perbrondum
Copy link
Author

I think I over complicated this request by driving the conversation into API cost. The real issue for us is that we need to generate X tasks instantaneously (or as fast as possible) so that a subsequent query either returns 0 or X records.
Having an update(object: , [SalesforceRecord]) that would return after creating X records would do just that. I can image other scenarios where this could come in handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants