Retrieves data from specified objects, whether or not they have been deleted.
QueryResult = sfdc.queryAll(string queryString);
Use queryAll to identify the records that have been deleted because of a merge or delete. queryAll has read-only access to the field isDeleted; otherwise it is the same as query().
SELECT id, isDeleted, masterRecordId FROM Account WHERE masterRecordId=’100000000000Abc’
You can use queryAll() to query on all Task and Event records, archived or not. You can also filter on the isArchived field to find only the archived objects. You cannot use query() as it automatically filters out all records where isArchived is set to true. You can update or delete archived records, though you cannot update the isArchived field. If you use the API to insert activities that meet the criteria listed below, the activities will be archived during the next run of the archival background process.
For additional information about using queryAll, see query().
private void querySample() {
QueryResult qr = null;
QueryOptions qo = new QueryOptions();
qo.setBatchSize(new Integer(250));
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),
"QueryOptions", qo);
try {
qr = binding.queryAll("select FirstName, LastName, IsDeleted from Contact");
boolean done = false;
if (qr.getSize() > 0){
System.out.println("Logged-in user can see " + qr.getRecords().length +
" contact records (including deleted records).");
while (!done) {
for (int i=0;i<qr.getRecords().length;i++) {
Contact con = (Contact)qr.getSize(i);
String fName = con.getFirstName();
String lName = con.getLastName();
boolean isD = con.isDeleted();
if (fName == null)
System.out.println("Contact " + (i + 1) + ": " + lName + " isDeleted = " + isD);
else
System.out.println("Contact " + (i + 1) + ": " + fName + " " + lName +
" isDeleted = " + isD);
}
if (qr.isDone()) {
done = true;
} else {
qr = binding.queryMore(qr.getQueryLocator());
}
}
}
else {
System.out.println("No records found.");
}
System.out.println("\nQuery succesfully executed.");
}
catch (RemoteException ex) {
System.out.println("\nFailed to execute query succesfully, error message was:
\n" + ex.getMessage()); }
}
private void queryAllSample()
{
QueryResult qr = null;
QueryOptions qo = new QueryOptions();
qo.batchSize = 250;
binding.QueryOptionsValue = qo;
try
{
qr = binding.queryAll("Select FirstName, LastName,IsDeleted from Account");
if (qr.size > 0)
{
Console.WriteLine("Logged-in user can see " + qr.records.Length + " Account");
while (true)
{
for (int i = 0; i < qr.records.Length; i++)
{
Account account = (Account)qr.records[i];
String name = account.Name;
bool? isD = account.IsDeleted;
Console.WriteLine("Account " + (i + 1) + ": " + name + "isDeleted = "
+ isD);
if (qr.done)
{
break;
}
else
{
qr = binding.queryMore(qr.queryLocator);
}
}
}
}
else
{
Console.WriteLine("No records found");
}
Console.WriteLine("QueryAll successfully executed.");
}
catch (Exception ex)
{
Console.WriteLine("\nFailed to execute query succesfully, error message
was: \n" + ex.Message);
}
}
| Name | Type | Description |
|---|---|---|
| queryString | string | Query string that specifies the object to query, the fields to return, and any conditions for including a specific object in the query. For more information, see Salesforce Object Query Language (SOQL). |