Button triggered with Hotkey - actions don't have latest input

  • 1
  • Problem
  • Updated 2 years ago
So I have created a search box and button using a field editor with a UI Only Field and a Page Title where the button is triggered when you hit Return by setting return as a hotkey for the button.

(You might ask why I didn't just use a normal table filter. It's complicated. There are reasons. I can provide details if needed.)

It works pretty well if you type some text and then click the button. It also works well if you type some text and then wait half a second and hit return.

But if you type some text and quickly hit return, the button is activated but the Actions for the button seem to be run before the text in the field is actually sent to it's model or more importantly to the condition for my SearchResults model.

Is there some way to delay the button's action until the value of the UI Only SearchString Field has been fully "set"?

Below is the XML for a test page. It searches Contacts based on their name.

To reproduce the issue: Try typing a name and clicking the search button. Then close the popup and type a new name and quickly hit return. The popup will show you that the SearchString and the SOQL are not the same because the condition is not getting the value from the SearchString in time.

Any help is appreciated.

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="false" showheader="false" theme="SubTabs">
<models>
<model id="SearchField" limit="20" query="false" createrowifnonefound="true" adapter="salesforce" type="" sobject="Contact" doclone="" unloadwarningifunsavedchanges="false">
<fields>
<field id="SearchString" uionly="true" displaytype="TEXT" label="Search"/>
<field id="LastSearch" uionly="true" displaytype="TEXT" label="Last Search" defaultValue="zxbzkjahsdkasm"/>
<field id="MatchSearch" uionly="true" displaytype="FORMULA" label="Match Search" readonly="true" returntype="BOOLEAN">
<formula>{{SearchString}}=={{LastSearch}}</formula>
</field>
<field id="PopUpOpen" uionly="true" displaytype="BOOLEAN" label="PopUpOpen"/>
</fields>
<conditions>
<condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Name"/>
</conditions>
<actions/>
</model>
<model id="SearchResults" limit="20" query="false" createrowifnonefound="false" adapter="salesforce" type="" sobject="Contact" doclone="" unloadwarningifunsavedchanges="false">
<fields>
<field id="Name"/>
<field id="MailingPostalCode"/>
</fields>
<conditions logic="1 and 2">
<condition type="blank" value="null" field="Name" operator="!=" enclosevalueinquotes="false"/>
<condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Name" state="filterableoff" inactive="true" name="Name" operator="contains"/>
</conditions>
<actions/>
</model>
</models>
<components>
<grid uniqueid="sk-2ftG-d-1032" rowgutter="0px" columngutter="10px">
<divisions>
<division behavior="flex" verticalalign="top" minwidth="1%" ratio="1">
<components/>
</division>
<division behavior="flex" verticalalign="center" ratio="15" minwidth="100px" cssclass="searchDivision">
<components>
<basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="SearchField" buttonposition="" uniqueid="sk-2ftKrV-1039" mode="edit" layout="" cssclass="searchEditor">
<columns layoutmode="responsive" columngutter="4px" rowgutter="4px">
<column cssclass="searchColumn" ratio="1" minwidth="300px" behavior="flex">
<sections>
<section title="Section A" collapsible="no" showheader="false">
<fields>
<field id="SearchString" valuehalign="" type="" cssclass="searchBox">
<label>Enter name of a Contact and hit return or click Search button:</label>
</field>
</fields>
</section>
</sections>
</column>
</columns>
<renderconditions logictype="and"/>
</basicfieldeditor>
</components>
</division>
<division behavior="fit" verticalalign="center">
<components>
<pagetitle uniqueid="sk-2ftLxX-1049" model="SearchField" cssclass="buttons">
<actions>
<action type="multi" label="Search" icon="sk-icon-search" cssclass="searchButton">
<actions>
<action type="blockUI" message="Searching..." timeout="9500"/>
<action type="setCondition" model="SearchResults" value="{{$Model.SearchField.data.0.SearchString}}" condition="Name"/>
<action type="requeryModel" model="SearchResults" behavior="standard"/>
<action type="showPopup">
<popup title="New Popup" width="90%">
<components>
<richtext multiple="false" uniqueid="sk-18G5So-265" model="SearchField">
<contents>&lt;p&gt;Search String: {{SearchString}}&lt;/p&gt;
</contents>
</richtext>
<richtext multiple="true" uniqueid="sk-18GLLq-287" model="SearchResults">
<contents>&lt;p&gt;Search Results Condition: {{$Model.SearchResults.conditions.1.value}}&lt;/p&gt;

&lt;p&gt;Search Results SOQL: {{$Model.SearchResults.soql}}&lt;/p&gt;
</contents>
</richtext>
</components>
</popup>
</action>
<action type="updateRow" fieldmodel="SearchField" value="{{SearchString}}" field="LastSearch" enclosevalueinquotes="true"/>
<action type="unblockUI"/>
</actions>
<hotkeys>
<hotkey modifiers="" key="return" ignoretextinputs="false"/>
</hotkeys>
<renderconditions logictype="and"/>
<enableconditions logictype="and">
<condition type="blank" operator="!=" fieldmodel="SearchField" sourcetype="fieldvalue" field="SearchString" value="null" enclosevalueinquotes="false"/>
</enableconditions>
</action>
</actions>
<renderconditions logictype="and"/>
</pagetitle>
</components>
</division>
<division behavior="flex" verticalalign="top" minwidth="1%" ratio="1">
<components/>
</division>
</divisions>
<styles>
<styleitem type="background" bgtype="none"/>
<styleitem property="margin-left" value="5%"/>
<styleitem property="margin-right" value="5%"/>
<styleitem property="border" value="2px solid rgb(41, 159, 197)"/>
<styleitem property="border-radius" value="5px"/>
<styleitem property="padding" value="3px 10px 3px 10px"/>
<styleitem property="margin-top" value="-5px"/>
</styles>
<renderconditions logictype="and"/>
</grid>
<skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="10" createrecords="false" model="SearchResults" buttonposition="" mode="readonly" uniqueid="sk-2fuFGD-1113" emptysearchbehavior="query" cssclass="searchResults">
<fields>
<field id="Name" valuehalign="" type="" allowordering="true"/>
<field id="MailingPostalCode"/>
</fields>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
<searchfields/>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="true" fieldmodel="SearchResults" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="hasRows"/>
</renderconditions>
</skootable>
</components>
<resources>
<labels/>
<javascript/>
<css/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>

Photo of Tony Sirna

Tony Sirna

  • 976 Points 500 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Tony Sirna

Tony Sirna

  • 976 Points 500 badge 2x thumb
I'm still looking for help on this issue if anyone has ideas.

Thanks!