I am very new at this and the answer is probably very simple, but please help.
I get the following returned from a query, this is a jsonParse of the result
{"totalSize":1,
"done":true,
"records":
[{"attributes":
{
"type":"Account",
"url":"/services/data/v21.0/sobjects/Account/001C0000012Z8Y5IAK"
},
"Id":"001C0000012Z8Y5IAK"
}]
}
How do I extract the Id at the end into a variable when totalSize = 1?
objectName.records[0].Id will do the trick. Increment records index appropriately.
Sample -
var sforceResponse = {"totalSize":1,"done":true,"records":[{"attributes":{"type":"Account","url":"/services/data/v21.0/sobjects/Account/001C0000012Z8Y5IAK"},"Id":"001C0000012Z8Y5IAK"}]}
sforceResponse.records[0].Id //this variable contains the Id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With