Skip to main content
September 27, 2021
Solved

Multiple writes to datastore

  • September 27, 2021
  • 4 replies
  • 0 views

I'm updating my database table using the "Write to Data Store Entity" I have an array of uploadId's that are my primary key. When writing to the DSE, I'm passing additional information like the current time now() and some other text values. 

In the error (see image below) you can clearly see that the first uploadId (10473) is passed with the additional information. However on the 2nd iteration (uploadId 10474) all of the additional values are null. How do I pass multiple values using this smart service?  

Thanks!

Best answer by peter.lewis

This is correct, but I'd also in general suggest providing your data at the parent level instead of at each individual field. To do this, you can update the existing variable using the update function or just iterate over it using a!forEach like this:

a!forEach(
  items: pv!uploadID,
  expression: type!DLS_DIM_AnalystResponse(
    uploadID: fv!item,
    updatedon: now()
  )
)

4 replies

September 27, 2021

You need to make the input into an array with the same length as the length of the array of uploadIds. So something like repeat(length(pv!uploadID), now())

peter.lewis
Employee
September 28, 2021

This is correct, but I'd also in general suggest providing your data at the parent level instead of at each individual field. To do this, you can update the existing variable using the update function or just iterate over it using a!forEach like this:

a!forEach(
  items: pv!uploadID,
  expression: type!DLS_DIM_AnalystResponse(
    uploadID: fv!item,
    updatedon: now()
  )
)

May 9, 2023
[deleted]
May 9, 2023