You need to sign in to do that
Don't have an account?
John Daly 3
Unbale to get sObject id
I am new to Sales force API integration with .NET and came accross this issue - can't seem to get the sObject id from QueryResult - the id is null, even though a valid record is returned, and I can see the Name field. Any suggestions?
See my query below:
string queryStr = $"SELECT id, Name FROM Account Where Name = '{name}'";
if (qResult.size > 0)
{
while(!done)
{
sObject[] records = qResult.records;
for(int i = 0; i < records.Length; i ++)
{
accountId = records[i].id; // record id is null here
}
if (qResult.done)
{
done = true;
}
else
{
}
}
See my query below:
string queryStr = $"SELECT id, Name FROM Account Where Name = '{name}'";
QueryResult qResult = _service.query(queryStr);
bool done = false;
bool done = false;
if (qResult.size > 0)
{
while(!done)
{
sObject[] records = qResult.records;
for(int i = 0; i < records.Length; i ++)
{
accountId = records[i].id; // record id is null here
}
if (qResult.done)
{
done = true;
}
else
{
qResult =
_service.queryMore(qResult.queryLocator);
}_service.queryMore(qResult.queryLocator);
}
}
Just try with "Id" instead of "id"
accountId = records[i].Id;
( upper-case for the "I" )
All Answers
Just try with "Id" instead of "id"
accountId = records[i].Id;
( upper-case for the "I" )
Old problem with id and Id :
https://developer.salesforce.com/forums/?id=9060G0000005aB1QAI
All is case insensitive in Apex/VFP by default excepted for the specific field Id (sometimes).
Best regards
Alain
getting System.ListException: Row with null Id at index 0 error with my Map AggregateResult
https://developer.salesforce.com/forums/?id=9060G000000XhsvQAC
Given that apex is case insentitive, id and Id should be the same.