Skip to main content
New Participant
Sep 27, 2021 10:31 PM UTC
Solved

Multiple writes to datastore

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!

peter.lewis
Employee
Sep 28, 2021 1:16 PM UTC

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

New Participant
Sep 27, 2021 11:48 PM UTC

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
Sep 28, 2021 1:16 PM UTC

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()
  )
)

New Participant
May 9, 2023 2:15 PM UTC
[deleted]
sanchitg0002
Inspiring
May 9, 2023 4:13 PM UTC