Conditions on salesforce formula fields not working

I haven’t gotten an answer to this post, but I’ve better identified the problem, so I’m re-posting with a more accurate title.

Here are the conditions on my model:

When I look up the model’s .soql property in the runtime console, I find this:

“SELECT Name,Id FROM Patient_Case__c WHERE (Patient__r.DefaultCenter__r.Name = ‘CompassCare’)”

The conditions on the First_Complete_Interaction_Date__c field are simply not being processed.
Does it matter that it is a salesforce formula field?


Have you tried dragging the !=null condition to the top of the list? What does the console soql query show in that case?

I know you’re a champion, but sometimes it’s the simple things that get overlooked. Are logic conditions being used? They aren’t smart like within salesforce, so if you specify anything in them they have to be updated manually with any new conditions.

Hey, Matt. Conditions on Salesforce formula fields are supported. The two quick things to check that come to mind are Condition Grouping Logic and permissions. If the User running the page doesn’t have access to First_Complete_Interaction_Date__c, the field will get stripped out of the query. An quick check would be to add that field to model’s fields list and see if you get any data back. If you do get data back, you can use our model API to check to see if a particular field is “filterable” in Salesforce:


Replace “PatientCases” out with your actual model name, run that from the console, and if you get back true, then the field should be usable in a model Condition.

Matt -

I put together a small sample of what I think you are trying to do and the model SOQL is correct. As Josh points out, possibly you have “grouping logic” specified that is resulting in skipping the conditions?

Aside from that, its difficult to say exactly what is going on. I tried with “process model client side” and “process client server side” and in both cases, SOQL is correct. I noticed that your second condition has a date of 2050. I thought possibly that was causing a problem but even with a condition of a date in 2050, the SOQL is correct.

Here’s my questions/suggestions:

  1. Are you checking the SOQL immediately after the page loads (before doing anything) or later on after doing a few things? If you’re not checking it right away, try checking it immediately after page load before doing anything else on the page. The problem could lie in some other action you have firing that is corrupting the conditions in some way.

  2. Can you use the sample below and try to recreate your situation using the standard Account objects? Narrowing down what might be causing the problem would be helpful for determining the root cause.

Sample Page XML

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Account">   <models>
      <model id="Account" limit="20" query="true" createrowifnonefound="false" adapter="" type="" sobject="Account" doclone="" processonclient="false">
            <field id="Name"/>
            <field id="Id"/>
            <condition type="param" value="id" field="Id" operator="=" enclosevalueinquotes="true" novaluebehavior="noquery"/>
      <model id="ChildAccounts" limit="1" query="true" createrowifnonefound="false" sobject="Account" adapter="" type="" doclone="" processonclient="false">
            <field id="Name"/>
            <field id="CreatedDate"/>
            <condition type="modelmerge" value="" field="Parent.Name" state="filterableon" inactive="false" name="ParentAccount" operator="=" model="Account" enclosevalueinquotes="true" mergefield="Name" novaluebehavior="noquery"/>
            <condition type="fieldvalue" value="2015-01-02T01:00:00.000Z" enclosevalueinquotes="false" field="LastUpdatedDate__c" operator="gte" state="filterableon" inactive="false" name="LastUpdatedDateStart"/>
            <condition type="fieldvalue" value="" enclosevalueinquotes="false" field="LastUpdatedDate__c" operator="lte" state="filterableoff" inactive="true" name="LastUpdatedDateEnd"/>
            <condition type="blank" value="null" field="LastUpdatedDate__c" operator="!=" enclosevalueinquotes="false"/>
      <pagetitle model="Account" uniqueid="sk-WJwE0-70">
            <action type="savecancel" window="self"/>
      <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="Account" buttonposition="" uniqueid="sk-WV126-82" mode="read">
            <column width="100%">
                  <section title="Section A" collapsible="no">
                        <field id="Name"/>
      <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="10" createrecords="false" model="ChildAccounts" buttonposition="" mode="readonly" uniqueid="sk-WV7Af-106" emptysearchbehavior="query">
            <field id="Name"/>
         <massactions usefirstitemasdefault="true"/>
            <view type="standard"/>
      <styleitem type="background" bgtype="none"/>

Looks like J was replying as I was creating the sample page.  He brings up a great point regarding permissions, that might be the culprit as well!

I agree with J’s point about permissions — Matt can you please confirm that the running user does / does not have access to the First_Complete_Interaction_Date__c field, and that it is filterable?

It’s always the permissions! Thanks, guys.

Why does the System Admin user not automatically have field-level permissions for all new fields? Every time I add a field I have to update the permission set?

Hey Matt - Glad you found the source of the issue.  Regarding permissions, how are you adding the fields?  If you are doing it through SFDC web interface, you should get a screen prompt for assigning permissions.  If you are doing it through manually modifying XML, you need to manually add field permission to profile.

Are you using Schema Builder or the regular New Custom Field wizard? The wizard prompts you to select profiles to grant access to at the end, but not Permission Sets. I can’t remember what Schema Builder does in terms of FLS.

I’ve been using the wizard. I guess I need to slow down and make sure that the System Admin has permission.

I wish I could update permission sets by default, since that’s where we handle our permissions.