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!