When a model contains custom condition group logic and when there is a subselect condition, when the user inputs search criteria (e.g. part of a name), the following exception is encountered:
Error:Semi join sub-selects are only allowed at the top level WHERE expressions and not in nested WHERE expressions.
The SOQL generated by Skuid doesn’t really align with the error message as it appears that it should be valid SOQL. Unfortunately, an exception is encountered nontheless. Possibly this is a SFDC bug?
Notes
- When the exception is encountered, no visible message is ever displayed to the user - instead, the user is just left to think that no results were found. You must check the response (in the Network tab) to see the actual error.
- There must be more than one condition on the model and it must have custom grouping logic. This is is causing Skuid to group the custom logic with parens and then add an AND with the “Like ‘%value%’” for each search field. It’s this extra clause that is grouped separately from the model conditions group that causes the SOQL to fail. The generated SOQL seems valid - SFDC bug?
This is the generated SOQL that fails:
SELECT Name,Id FROM Account
WHERE (
(IsDeleted = false)
OR
(
Id not in (
SELECT AccountId
FROM Contact
)
)
)
AND
(
(
(Name LIKE '%foobar%')
)
)
Steps to reproduce:
- Create page using XML below
- Preview page picking existing account
- Type a value in to the Account field to cause a search to occur
Expected Result
Search results are returned based on value input
Actual Result
“Error:Semi join sub-selects are only allowed at the top level WHERE expressions and not in nested WHERE expressions.” is encountered although not visible anywhere to user.
Sample Page XML
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Contact"> <models>
<model id="Contact" limit="1" query="true" createrowifnonefound="false" sobject="Contact" adapter="" type="">
<fields>
<field id="FirstName"/>
<field id="LastName"/>
<field id="CreatedDate"/>
<field id="AccountId"/>
<field id="Account.Name"/>
<field id="Account.Id"/>
</fields>
<conditions>
<condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
</conditions>
<actions/>
</model>
<model id="AccountSearch" limit="" query="false" createrowifnonefound="false" adapter="" type="" sobject="Account" doclone="no" processonclient="true">
<fields>
<field id="Name"/>
<field id="Id"/>
</fields>
<conditions logic="1 OR 2">
<condition type="fieldvalue" value="false" enclosevalueinquotes="false" field="IsDeleted"/>
<condition type="join" value="" operator="not in" enclosevalueinquotes="true" field="Id" joinobject="Contact" joinfield="AccountId"/>
</conditions>
<actions/>
</model>
</models>
<components>
<pagetitle model="Contact" uniqueid="sk-2NOem-71">
<maintitle>
<template>{{FirstName}} {{LastName}}</template>
</maintitle>
<subtitle>
<template>{{Model.label}}</template>
</subtitle>
<actions>
<action type="savecancel" window="self"/>
</actions>
</pagetitle>
<basicfieldeditor showsavecancel="false" showheader="true" model="Contact" mode="edit" uniqueid="sk-2NOem-72" buttonposition="">
<columns>
<column width="100%">
<sections>
<section title="Basics">
<fields>
<field id="AccountId" valuehalign="" type="" optionsource="model" optionmodel="AccountSearch">
<searchfields>
<searchfield query="true" return="true" show="true" field="Name" operator="contains"/>
</searchfields>
</field>
<field id="FirstName"/>
<field id="LastName"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
<resources>
<labels/>
<css/>
<javascript/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>