You need to sign in to do that
Don't have an account?

using queryMore?
Hi, I just realized that my queries are only returning 200 records at a time. I'm trying to get all records (the specific user I'm working with has 411 records), but I'm not sure how to use queryMore.
I have my soql statement that's returning 200 records and then after that I have:
if (taskSql.done == "false"){
sforceClient.queryMore(taskSql);
}
but it's not working. I've also tried it with false not in quotes.
Anyway, if someone could give me a quick how-to for using the queryMore function in javascript, that would be grand.
Thanks,
-Zach
I have my soql statement that's returning 200 records and then after that I have:
if (taskSql.done == "false"){
sforceClient.queryMore(taskSql);
}
but it's not working. I've also tried it with false not in quotes.
Anyway, if someone could give me a quick how-to for using the queryMore function in javascript, that would be grand.
Thanks,
-Zach
----------------------------------------------------------------
QueryResult qr = binding.query(YOUR QUERY)
notfinished=true;
while (notfinished)
{
if (qr.size > 0 )
{
if (qr.done)
{
notfinished= false;
}
else
{
qr = binding.queryMore(qr.queryLocator);
}
}
}
------------------------------------------------------------------
Good luck
Gareth.
var notfinished;
var taskSql = new Array();
taskSql = sforceClient.query("Select SOAR_Tracking__c, Call_Duration__c, Purpose__c, Scheduled_First_Appointment__c, ActivityDate, Type from Task where ownerid = '"+globalUserId+"' and (type = 'Outbound Call' or type = 'Foot Canvas') and (activitydate "+lastFridayArraySearch[12]+")");
notfinished=true;
while (notfinished){
if (taskSql.size > 0 ){
if (taskSql.done){
notfinished = false;
} else {
taskSql = sforceClient.queryMore(taskSql.queryLocator);
}
}
}
//document.write(taskSql);
//alert(taskSql);
Message Edited by zach on 02-06-2006 12:27 PM
Sorry we are a C# shop so I may be missing something subtle - but what you've done looks fine.
The only reason it would hang up is if it gets caught in the while loop. This can only happen in two conditions:
1. If setting notfinished=flase does not exit the loop. This may be an issue since it's not c# and there may be a subtle difference - you can try changing the loop to be "while (notfinished==true)" I'd check that in a dummy loop of your own.
2. If the test on taskSQl.done is not returning true [which is almost the logical opposite of 1]
What I'd do is run it through the debugger and see what values you are getting for taskSQL.done and taskSQL.size. If you have a batch size of 200 and 412 records you should see taskSQL.size return the sequence 200,200, 12 and taskSQLdone = false,false,true
You may just want to pop up a message box and have a look at that.
If you are constantly returning 200,200,200,200 and false,false,false,false then It points to something wrong in the querylocator, and I am not sure I know how to start debugging that, but I am sure that you'd not be the first to notice if it were a bug there.
The code I posted is tested and working (against API v6)
G.
Use while (notfinished == true) { ... }
From quirksmode:
Checking a variable
Above we have seen that we can use Boolean logic in a statement like
A second way to use Boolean logic is to see if something exists or not. For instance
In this example the code is executed if
x
does NOT exist (x=false
).x is false
x=0
). So if the output of some calculation is that x is zero, x is false and the code is executed.x=''
). So if x is a string but has been made empty by some calculation, x is false and the code is executed.x=false
). Now x is a boolean variable and since it it false the code is executed.In all other cases x is true and the code is not executed. Note that you must define the variable
x
somewhere or the browser will complain.Here is a good place to learn about javascript. http://www.quirksmode.org/js/boolean.html