Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

Use a SOSL query with a sub SOQL query

公開日: Oct 13, 2022
説明
In SOSL if you are using SOQL to fetch the records to be compared by 'IN' Or 'NOT IN' operator,  the SOSL throws an exception: System.QueryException: unexpected token: 'common.api.soap.parse.SoapParseNode' :

Example query throwing exception:
 
FIND 'Test' IN NAME FIELDS 
	RETURNING Campaign (
		Id WHERE Id IN (
			SELECT CampaignId 
				FROM CampaignMember 
				WHERE ContactId = '003J000000mmEZp'
		) 
	LIMIT 2000)
解決策

The Exception is being thrown by SOSL as it does not support SOQL as a subquery. 

Also the records which are being compared by 'NOT IN' or 'IN'  should be surrounded by single quotes. 
 
Reference Doc:
Introduction to SOQL and SOSL
 
Example: Firstly, the SOQL which is being used as a sub query in SOSL should be used separately. 
 
SELECT CampaignId 
FROM CampaignMember 
WHERE ContactId = '003J000000mmEZp'
Secondly, use the records as a string and each record surrounded by single quotes.
 
For Example: 
FIND 'Test' IN NAME FIELDS 
RETURNING Campaign (Id 
WHERE Id IN ('701J00000006dJNIAY', '701J00000006dJNIAY','701J00000006tzhIAA','701J00000006c5kIAA','701J00000006c5QIAQ') 
LIMIT 2000)

NOTE: Please refer to this IDEA to support SOQL as the inner part of SOSL.
 
ナレッジ記事番号

000386684

 
読み込み中
Salesforce Help | Article