2010年12月19日日曜日

SOSL Find

1)
List<List<sObject>> results = [find {4155557000}
in phone
fields
returning contact(id, phone, firstname, lastname),
lead(id, phone,
firstname, lastname), account(id, phone, name)];
sObject[] records =
((List<sObject>)results[0]);
if (!records.isEmpty()) {
for (Integer
i = 0; i < records.size(); i++) {
sObject record = records[i];
if
(record.getSObjectType() == Contact.sObjectType) {
contacts.add((Contact)
record);
} else if (record.getSObjectType() ==
Lead.sObjectType){
leads.add((Lead) record);} else if
(record.getSObjectType() == Account.sObjectType) {
accounts.add((Account)
record);
}
}
}

2)
List<List<SObject>> searchList = [FIND 'map*' IN ALL FIELDS
RETURNING Account (id, name),
Contact, Opportunity, Lead];

0 件のコメント:

コメントを投稿