2012-05-07 42 views
0

我想用SOSL來獲得關係值嗎?我們可以在SOSL查詢中有關係嗎

List<List<SObject>> searchList = [FIND :mySearchText IN ALL FIELDS 
           RETURNING 
           Account (id, name,phone, BillingStreet,BillingCity,BillingState, ownerID.Alias,ownerID.MobilePhone)]; 

我得到一個錯誤

Save error: Didn't understand relationship 'ownerID' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. 

是不是我做錯了什麼?

回答

4

您可以訪問關係,但需要使用Owner.UserField而不是OwnerId.UserField

這應該爲你工作:

List<List<Account>> searchList = [FIND 'test' IN ALL FIELDS RETURNING 
    Account (id, name, phone, BillingStreet, BillingCity, BillingState, 
    OwnerId, Owner.Alias, Owner.MobilePhone)]; 

system.debug(searchList[0][0].Owner.Alias); 
system.debug(searchList[0][0].Owner.MobilePhone); 
+0

感謝...我怎麼錯過... :) – Prady

+0

不客氣! :) –

+0

嗨@MattK,我正在嘗試這樣的事情,但它沒有奏效。 Plz的幫助。我的目標是獲取帳戶名稱。在返回聯繫人(姓名,帳戶名稱,電子郵件地址),姓名(姓名,公司名稱,電子郵件地址)的姓名字段中查找{go *}' – surajs21

相關問題