Git Product home page Git Product logo

Comments (4)

mike4aday avatar mike4aday commented on May 26, 2024

@pbrondum what do you mean by 'cut off'? What was the error(s)?

There are at least 3 options for 100-1000 records - the standard Salesforce REST API currently only supports 1 insert per call. (I will open an enhancement request for better support within Swiftly Salesforce for multi-record inserts that implements 1+ of the options below.)

  1. Use when(fulfilled:) with an array of 100-1000 insert methods as the argument. Note that when is a PromiseKit method, so you'd need to import PromiseKit in your code (it is already included as the sole dependency of Swiftly Salesforce) and the inserted records must all be of the same type. You can see examples of when here: http://promisekit.org/docs/

  2. Use Swiftly Salesforce's Salesforce.custom method with the composite API endpoint and build the payload yourself. The composite API only supports up to 25 inserts, so you'd probably need to bundle these together in a when as above. And each sub-request 'costs' 1 API call, so there is no quota savings from using the composite API. See: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_composite.htm

  3. Use the Salesforce.custom method with the SOAP API endpoint to insert up to 200 records. I haven't tried this yet, so don't know for sure if it'd work.

If you are willing to poll for the asynchronous results, you could use the Bulk API to insert multiple records: https://resources.docs.salesforce.com/sfdc/pdf/api_asynch.pdf

from swiftlysalesforce.

 avatar commented on May 26, 2024

from swiftlysalesforce.

mike4aday avatar mike4aday commented on May 26, 2024

@pbrondum try creating an array of promises from ALL_TEMPLATES with map and then use that array as the argument to when -- something like this:

import PromiseKit
...
let promises = ALL_TEMPLATES.map {
    template in 
    let fields = ...
    return salesforce.insert(type: "WiWo_Template__c", fields: fields)
}
when(fulfilled: promises).then {
   // Do something with the results
}.catch {
  // Handle error
}

from swiftlysalesforce.

 avatar commented on May 26, 2024

from swiftlysalesforce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.