• DMonster
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Anyone know an easy way to query the primary contact ID for an account using the AccountId ?
The API seems to be lacking. The field IsPersonAccount is part of the Account but I get an error when I try to select it in my query against "Account".
The code below works fine using the development test account login. When I switch to the production login I get an error:
 
 qr = objSF.queryAll("select Id, Name, OwnerId from Opportunity");
for(int i=0; i < qr.size; i++)
                     {
                         sObject account = qr.records[i];
                         Response.Write("<br><br>Opportunity Name: " + getFieldValue("Name", account.Any) + "<br>Owner: " + getFieldValue("OwnerId", account.Any) + "<br>ID: " + getFieldValue("Id", account.Any));
                     }
 
I get this error:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
However, I just pull qr.records[5] or some other value it works. I noticed that using qr.records[qr.size] or qr.records[qr.size -1] also produces the error. It's like the size (qr.size) is not correct ; larger than it should be???
 
Any ideas? Again, works fine in development mode. Fails with production login.
 
 
The code below works fine using the development test account login. When I switch to the production login I get an error:
 
 qr = objSF.queryAll("select Id, Name, OwnerId from Opportunity");
for(int i=0; i < qr.size; i++)
                     {
                         sObject account = qr.records[i];
                         Response.Write("<br><br>Opportunity Name: " + getFieldValue("Name", account.Any) + "<br>Owner: " + getFieldValue("OwnerId", account.Any) + "<br>ID: " + getFieldValue("Id", account.Any));
                     }
 
I get this error:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
However, I just pull qr.records[5] or some other value it works. I noticed that using qr.records[qr.size] or qr.records[qr.size -1] also produces the error. It's like the size (qr.size) is not correct ; larger than it should be???
 
Any ideas? Again, works fine in development mode. Fails with production login.