• keefriffhardIII
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 7
    Replies

I have successfully built a relationship query such as

 

 SELECT Id,Name (SELECT contact.Id, contact.Name FROM Account.Contacts) FROM Account WHERE ....

 

I understand how to do nested loops to parse the results where you have to have the inner query results use its own query results processing.

 

Example (VB.Net)

 

bMoreToFetch = True

While bMoreInfoToFetch 

  

   ' loop through current set of records.... (outter loop)

   For Each oEnterpriseSObject In qrEnterprise.records

 

         oAcct = oEnterpriseSObject

         :

         

         ' loop through related records in the query

         qrEnterprise2 = oAcct.Contacts

         If qrEnterprise2 IsNothing = False Then

               bMoreContactsToFetch = true   

               While bMoreContactsToFetch                       

                    jmax = qrEnterprise2.records.Length - 1

                    For j = 0 To jmax

                       oContact = qrEnterprise2.records(i)

                       :

                    Next

                               

                    bMoreContactsToFetch = Not qrEnterprise2.done

                    If qrEnterprise2.done = False Then

                        oEnterpriseWebService.queryMore(qrEnterprise2.queryLocator)

                    End If

               End  While 

        

         End if ' if there are relationship records

 

   Next ' end of outter loop

 

  

   bMoreInfoToFetch = Not qrEnterprise.done

   If qrEnterprise.done = False Then

        oEnterpriseWebService.queryMore(qrEnterprise.queryLocator)

   End If

 

End While

 

The above (not the actual code - but the type of logic used) works but  grinds away forever.

 

 I put in some diagnostics and found that the outter loop was repeating the same objects (in this case accounts).

 

Almost seems as if the queryresult.done and queryMore(...queryLocator) isn't in sync with the processing.

 

So if I for example I do a query that returns 20 Account records

If I query just the Accounts by themselves, it works fine.

But I found when I did the relationship query (the inner SELECT..)  the outter iteration went beyond 20 and started repeating (the same account).

 

So again, I suspect it has something to do with the QueryResult object and not being in sync with the processing

I tried various things by asking myself "How does it now I processed the rows in the outter and inner loop?" but I can't get it to stop repeating itself (looking at the same data).

 

I have proven the code I am using works okay.

  • With the same exact code I put in the query without the relationship and it works fine.
  • With the same exact code I put in a query that returns 1 account record with 1 child - Ok.  I put in a query that returns 3 accounts where 2 have contacts and 1 doesn't , also okay.

 So I am thinking it has something to do with record count and muliple outter records - I haven't tried too many combinations especially since I have proven the code I am using works fine for small sets and for the outter query by itself.

 

I have successfully built a relationship query such as

 

 SELECT Id,Name (SELECT contact.Id, contact.Name FROM Account.Contacts) FROM Account WHERE ....

 

I understand how to do nested loops to parse the results where you have to have the inner query results use its own query results processing.

 

Example (VB.Net)

 

bMoreToFetch = True

While bMoreInfoToFetch 

  

   ' loop through current set of records.... (outter loop)

   For Each oEnterpriseSObject In qrEnterprise.records

 

         oAcct = oEnterpriseSObject

         :

         

         ' loop through related records in the query

         qrEnterprise2 = oAcct.Contacts

         If qrEnterprise2 IsNothing = False Then

               bMoreContactsToFetch = true   

               While bMoreContactsToFetch                       

                    jmax = qrEnterprise2.records.Length - 1

                    For j = 0 To jmax

                       oContact = qrEnterprise2.records(i)

                       :

                    Next

                               

                    bMoreContactsToFetch = Not qrEnterprise2.done

                    If qrEnterprise2.done = False Then

                        oEnterpriseWebService.queryMore(qrEnterprise2.queryLocator)

                    End If

               End  While 

        

         End if ' if there are relationship records

 

   Next ' end of outter loop

 

  

   bMoreInfoToFetch = Not qrEnterprise.done

   If qrEnterprise.done = False Then

        oEnterpriseWebService.queryMore(qrEnterprise.queryLocator)

   End If

 

End While

 

The above (not the actual code - but the type of logic used) works but  grinds away forever.

 

 I put in some diagnostics and found that the outter loop was repeating the same objects (in this case accounts).

 

Almost seems as if the queryresult.done and queryMore(...queryLocator) isn't in sync with the processing.

 

So if I for example I do a query that returns 20 Account records

If I query just the Accounts by themselves, it works fine.

But I found when I did the relationship query (the inner SELECT..)  the outter iteration went beyond 20 and started repeating (the same account).

 

So again, I suspect it has something to do with the QueryResult object and not being in sync with the processing

I tried various things by asking myself "How does it now I processed the rows in the outter and inner loop?" but I can't get it to stop repeating itself (looking at the same data).

 

I have proven the code I am using works okay.

  • With the same exact code I put in the query without the relationship and it works fine.
  • With the same exact code I put in a query that returns 1 account record with 1 child - Ok.  I put in a query that returns 3 accounts where 2 have contacts and 1 doesn't , also okay.

 So I am thinking it has something to do with record count and muliple outter records - I haven't tried too many combinations especially since I have proven the code I am using works fine for small sets and for the outter query by itself.

 

is it possible to do a salesforce to salesforce connection between a production org and a sandbox org?

 

when creating a connection from production to sandbox i've tried changing the connection link from "login.salesforce.com" to "test.salesforce.com" but i get a 

 

"Salesforce to Salesforce: Partner org is not active and no API calls are allowed"

 

But both sandbox and production are Enterprise orgs with plenty of API calls still left for the 24 hours period. i have used the api to push data into both.

  • March 31, 2011
  • Like
  • 0