Filtering on NetworkScope Returns UnsupportedQueryExpressionException

Free edition only - Deprecated


When trying to use the sfnetworkscope field to filter on a specific community ID, the query works when used alone, but fails when trying to add a second query layer. This can happen, for example, when using the NOT operator, as such:

NOT @sfnetworkscope="Your Community Id"

The query returns a Something Went Wrong error with the following message under More Information:

 "status": 400,
  "message": "The query expression of type BinaryFieldExpression can't be converted to SOQL/SOSL: @sfnetworkscope="Your Community Id". NetworkScope filters can only be top-level AND expressions",
  "type": "UnsupportedQueryExpressionException",
  "name": "UnsupportedQueryExpressionException",


This error is due to a SOSL limitation from Salesforce, which prevents the networkscope field from being used outside of top-level AND expressions. When using terms such as NOT, the networkscope query becomes outside of top-level AND expressions.


Ensure that the sfnetworkscope field is used only as top-level AND expressions. This means that, while you can’t use NOT, you can use @sfnetworkscope=(your first community Id, your second community Id, your third community Id).

Recommended Articles