How to Insert 1000+ records into Write to datastore Entity at a time

Certified Senior Developer

for example my array size is 3400

in the first write - 1 to 1000
2nd time write 1001 to 2000
3rd time write 2001 to 3000
4th time write 3001 to 3400

How we can achieve this one 

can anyone help me out 

TIA

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Prepare Array: Create an array with 3400 records.

    Define Batch Size: Set batch size (e.g., 1000).

    Use Loop:

    • Loop through the array in increments of the batch size.
    • Use Write to Data Store Entity for each batch.


    forEach( items: a!arrayRange(1, ceiling(length(recordsArray) / batchSize)), expression: a!writeToDataStoreEntity( dataStoreEntity: cons!YOUR_DATA_STORE_ENTITY, valueToStore: a!arraySlice(recordsArray, (fv!item - 1) * batchSize + 1, fv!item * batchSize) ) )

Reply
  • 0
    Certified Senior Developer

    Prepare Array: Create an array with 3400 records.

    Define Batch Size: Set batch size (e.g., 1000).

    Use Loop:

    • Loop through the array in increments of the batch size.
    • Use Write to Data Store Entity for each batch.


    forEach( items: a!arrayRange(1, ceiling(length(recordsArray) / batchSize)), expression: a!writeToDataStoreEntity( dataStoreEntity: cons!YOUR_DATA_STORE_ENTITY, valueToStore: a!arraySlice(recordsArray, (fv!item - 1) * batchSize + 1, fv!item * batchSize) ) )

Children
No Data