no results returned when lookup filter applied to new record "Id" field

  • 1
  • Problem
  • Updated 4 years ago
  • Acknowledged
Hello -

When a lookup filter is applied on a field of a "new" record, if the filter uses the "Id" of the new record, the lookup results are coming back empty.  The same logic applied to an existing record works as expected so the issue is specific to 'new' records in a model.  Since, under the covers, skuid is assigning an "Id" to new rows (e.g. "1", "2", etc.), I would expect that rows should be retrieved that don't match the "Id" value (which is basically every record in that object on the server).

An example of this is on Account which contains a Parent account field.  The lookup filter on Parent Account is written to not include the current account id so that the user can not mistakenly self-reference an account as its parent.

Below is a sample page that demonstrates the issue.  The field "Parent Account (Without Filter)" has no filter applied while "Parent Account (With Filter)" has a filter "Id" not equal to field from current row "Id"

<skuidpage showsidebar="true" showheader="true" tabtooverride="Account">   <models>
      <model id="Account" limit="1" query="true" createrowifnonefound="true" sobject="Account">
         <fields>
            <field id="Name"/>
            <field id="ParentId"/>
            <field id="Parent.Name"/>
         </fields>
         <conditions>
            <condition type="param" value="id" field="Id" operator="=" enclosevalueinquotes="true"/>
         </conditions>
      </model>
   </models>
   <components>
      <pagetitle model="Account">
         <maintitle>
            <template>New {{Model.label}}</template>
         </maintitle>
         <subtitle>
            <template>{{Model.labelPlural}}</template>
         </subtitle>
         <actions>
            <action type="savecancel" afterCancel="/{{Model.KeyPrefix}}/o" afterSave="/{{Id}}"/>
         </actions>
      </pagetitle>
      <basicfieldeditor showsavecancel="false" showheader="true" model="Account" mode="edit">
         <columns>
            <column width="100%">
               <sections>
                  <section title="Basics">
                     <fields>
                        <field id="Name"/>
                        <field id="ParentId">
                           <label>Parent Account ID (Without Filter)</label>
                        </field>
                        <field id="ParentId">
                           <label>Parent Account ID (With Filter)</label>
                           <filters>
                              <filter type="dependent" operator="!=" field="Id" value="" enclosevalueinquotes="true" depfield="Id"/>
                           </filters>
                        </field>
                     </fields>
                  </section>
               </sections>
            </column>
         </columns>
      </basicfieldeditor>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript/>
   </resources>
</skuidpage>
Having a separate "edit" and "new" page for account creation would provide a workaround but trying to avoid having two versions of this page when this situation occurs.  We have self-referencing fields throughout our object model so that would mean we would have separate "new" & "edit" pages for our objects strictly to workaround this issue.

This is another scenario where being able to apply conditional logic to conditions/filters would be very beneficial.  We could say "where not new OR Id != Id".

Assistance, as always, is appreciated!



Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Is this what your looking for? If you click on the conditions section of the model you can define the grouping logic like "1 AND (2 OR 3)".



Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
This might also be helpful.


Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Barry,

We can confirm that this is an issue with Lookup Filters on new records. The SOQL for the lookup query is failing because Skuid's "new" Ids, which start out at "1" and advance incrementally upwards as needed, do not qualify as valid Salesforce Ids, so the SOQL Id field conditions are failing.

For other's understanding, here is a screenshot of what Barry's sample page looks like:






We'll add this to our issues list and let you know when it is resolved.

Regards,

Zach
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Moshe - Thanks for the assist!  Unfortunately, as Zach pointed out in the screen shots, the situation applies to a lookup filter on a field not on a model so the grouping options aren't available unfortunately.

Zach - Appreciate the quick reply and confirmation.  I was thinking that it might be SFDC that bails on the query because the "id" isn't in a proper format.  Keep us posted and thank you!

For others that encounter this, my workaround is to have two instances of the same field on the page where it is needed and use conditional rendering to display the one that has the 'id' filter on it where CreatedDate != blank (existing records) and the other which doesn't have the 'id' filter where CreatedDate = blank (new records).  This avoids having to have separate new & edit pages.