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

Improper Record Result type on sobject.update #1315

Closed
JakeOrel opened this issue Mar 22, 2023 · 1 comment
Closed

Improper Record Result type on sobject.update #1315

JakeOrel opened this issue Mar 22, 2023 · 1 comment
Labels
fixed in v3 fixed in jsforce v3

Comments

@JakeOrel
Copy link

JakeOrel commented Mar 22, 2023

Hey y'all
Im working with updating multiple records using sobject.update
For some reason the typing result is RecordResult instead of a RecordResult array even tho the actual response is an array.
I have confirmed that the call is hitting the updateMany function stored on connection.

Versions :

  • JSForce Version: 1.11
  • api version: .42
  • node version: 16.l19.1

the call is successful however I'm not able to loop through the array of results because typescript thinks that it is a singular RecordResult

please let me know if you have any insight

Actual Behavior

  • type of result whether in callback or async await is type RecordResult so i am unable to loop through results without using @ts-ignore

Expected Behavior

  • Result to be typed as RecordResult[] to allow me to loop through RecordResults to search for errors

code example

const records = [{Id: ...}, {Id: ...}, {Id: ...}]
const result = await connection.sobject('type').update(records)
 console.log(result) <-- this is type RecordResult not RecordResult[]

console.log(result[0]) <-- Element implicitly has an 'any' type because expression of type '0' can't be used to index type 'RecordResult'.
  Property '0' does not exist on type 'RecordResult'

ALTERNATE

const records = [{Id: ...}, {Id: ...}, {Id: ...}]
connection.sobject('Type').update(records).then( (err, result) => {
   if (err) {
     console.error(err) 
  }
  console.log(result[0]) Same issue as above
})
.catch(err => console.error(err))
@cristiand391 cristiand391 added the fixed in v3 fixed in jsforce v3 label May 13, 2024
@cristiand391
Copy link
Member

This should be fixed in v3, see: #1529

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

No branches or pull requests

2 participants