Hi is it possible to capture the out of box search field value from the table search? In my user case, if user does not find a match, I want to allow them to save that search term. Is that possible?
Hi Jill, are you imagining a scenario in which a search that returns no results can be turned into a new record?
exactly! It’s simpler than that for now. I just need to save that search text in a text field.
I see. Here’s some XML for an example page that takes one possible approach. This makes use of a UI-only field with a button set in a sort of search field. Using this field with the action framework and some conditions, you can set up behavior like what you’re describing. I’ve got this page set to copy the search term over to a new Account record, but you could easily swap that field out for a text field. I hope this helps you in dreaming up your solution!
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Contact"> <models>
<model id="SearchUIModel" query="true" createrowifnonefound="true" datasource="Ui-Only" processonclient="true">
<fields>
<field id="SearchTerm" displaytype="TEXT" label="Search Term"/>
<field id="DisplayNewRecordEditor" displaytype="BOOLEAN" label="DisplayNewRecordEditor" ogdisplaytype="TEXT" defaultvaluetype="fieldvalue"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="NewContact" limit="1" query="false" createrowifnonefound="false" datasource="salesforce" sobject="Contact" type="">
<fields>
<field id="FirstName"/>
<field id="LastName"/>
<field id="CreatedDate"/>
<field id="Email"/>
<field id="Phone"/>
<field id="Name"/>
</fields>
<conditions>
<condition type="modelmerge" value="" field="Name" operator="contains" model="SearchUIModel" enclosevalueinquotes="true" mergefield="SearchTerm" novaluebehavior="deactivate" state="filterableoff" inactive="true" name="SearchTermCondition"/>
</conditions>
<actions/>
</model>
<model id="Accounts" limit="200" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Account">
<fields>
<field id="Name"/>
<field id="Phone"/>
<field id="BillingCity"/>
<field id="Industry"/>
</fields>
<conditions>
<condition type="modelmerge" value="" field="Name" operator="contains" model="SearchUIModel" enclosevalueinquotes="true" mergefield="SearchTerm" novaluebehavior="deactivate" state="filterableoff" inactive="true" name="SearchTerm"/>
</conditions>
<actions/>
</model>
<model id="NewAccount" limit="1" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Account">
<fields>
<field id="Name"/>
<field id="Phone"/>
<field id="BillingCity"/>
<field id="Industry"/>
</fields>
<conditions>
<condition type="modelmerge" value="" field="Name" operator="contains" model="SearchUIModel" enclosevalueinquotes="true" mergefield="SearchTerm" novaluebehavior="deactivate" state="filterableoff" inactive="true" name="SearchTerm"/>
</conditions>
<actions/>
</model>
</models>
<components>
<grid uniqueid="sk-1E7uGR-164">
<divisions>
<division behavior="flex" minwidth="100px" ratio="1" verticalalign="top">
<components>
<basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="SearchUIModel" buttonposition="" uniqueid="sk-1E7GaS-140" mode="edit">
<columns>
<column width="100%">
<sections>
<section title="Section A" collapsible="no" showheader="false">
<fields>
<field id="SearchTerm" valuehalign="" type="">
<label>Search Accounts by Name</label>
</field>
</fields>
</section>
</sections>
</column>
</columns>
<renderconditions logictype="and"/>
</basicfieldeditor>
</components>
</division>
<division behavior="fit" verticalalign="top">
<components>
<buttonset model="SearchUIModel" uniqueid="sk-1E7yWi-177">
<buttons>
<button type="multi" label="Search" icon="sk-icon-search">
<actions>
<action type="activateCondition" model="Accounts" condition="SearchTerm"/>
<action type="requeryModel" model="Accounts" behavior="standard">
<onerroractions>
<action type="blockUI" message="There was an error" timeout="3000"/>
</onerroractions>
</action>
</actions>
</button>
<button type="multi" label="New Account" icon="sk-icon-arrow-right">
<actions>
<action type="createRow" model="NewAccount" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context">
<defaults>
<default type="fieldvalue" field="Name" enclosevalueinquotes="true" value="{{$Model.SearchUIModel.data.0.SearchTerm}}"/>
</defaults>
</action>
<action type="updateRow" model="SearchUIModel" fieldmodel="SearchUIModel" affectedrows="context" field="DisplayNewRecordEditor" enclosevalueinquotes="false" value="true"/>
</actions>
<renderconditions logictype="and">
<rendercondition fieldmodel="Accounts" sourcetype="modelproperty" nosourcerowbehavior="skipandnorender" sourceproperty="hasNoRows"/>
</renderconditions>
<enableconditions logictype="and"/>
</button>
</buttons>
<renderconditions logictype="and"/>
</buttonset>
</components>
</division>
<division behavior="flex" verticalalign="top" minwidth="100px" ratio="1">
<components>
<basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="NewAccount" buttonposition="" uniqueid="sk-1E9I8P-242" mode="edit">
<columns>
<column width="100%">
<sections>
<section title="New Section" collapsible="no" showheader="false">
<fields>
<field id="Name" valuehalign="" type=""/>
<field id="Phone"/>
<field id="BillingCity"/>
<field id="Industry"/>
</fields>
</section>
</sections>
</column>
</columns>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" operator="=" enclosevalueinquotes="false" fieldmodel="SearchUIModel" sourcetype="fieldvalue" nosourcerowbehavior="deactivate" field="DisplayNewRecordEditor" value="true"/>
</renderconditions>
</basicfieldeditor>
</components>
</division>
</divisions>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</grid>
<skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Accounts" mode="read" allowcolumnreordering="true" uniqueid="sk-1E6ucn-87" emptysearchbehavior="query">
<fields>
<field id="Name" hideable="true" uniqueid="fi-1EDQCs-624"/>
<field id="Phone" hideable="true" uniqueid="fi-1EDQCs-625"/>
<field id="BillingCity" hideable="true" uniqueid="fi-1EDQCs-626"/>
<field id="Industry" hideable="true" uniqueid="fi-1EDQCt-627"/>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="massupdate"/>
<action type="massdelete"/>
</massactions>
<views>
<view type="standard"/>
</views>
<searchfields/>
</skootable>
</components>
<resources>
<labels/>
<css/>
<javascript/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>
Hi thanks very much for the help on this! I think I confused you. I wanted to get the value in the table search box.
I see you are using new features from Brooklyn. The UI only model is not showing up the fields though:
I’ve set up an example similar to yours in my sandbox. I wanted to use the table SOSL search option so I wanted to see if I can get the value in the table search box so that I can have a button like a global action right next that so that I don’t see the custom search in another location e.g. on top of the table. Hope that makes sense.
Thanks!
Jill,
Here is sample page that I think demonstrates what you are trying to do. It’s based on a Contact model, but the setup is similar for Accounts. You need a small snippet to grab the contents of the search box and set the name field of the model you are using to create a new record. I added a button ‘New Contact from Search’ that grabs the contents of the search box and adds it to the popup to create a new contact record.
Thanks,
Bill
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Contact"> <models>
<model id="Contact" limit="100" query="true" createrowifnonefound="false" datasourcetype="salesforce" datasource="salesforce" sobject="Contact">
<fields>
<field id="FirstName"/>
<field id="LastName"/>
<field id="CreatedDate"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="NewContact" limit="1" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Contact">
<fields>
<field id="FirstName"/>
<field id="LastName"/>
</fields>
<conditions/>
<actions/>
</model>
</models>
<components>
<pagetitle model="Contact" uniqueid="sk-1OB6y--94">
<maintitle>
<template>{{Model.labelPlural}}</template>
</maintitle>
<subtitle>
<template>Home</template>
</subtitle>
<actions>
<action type="savecancel"/>
</actions>
</pagetitle>
<skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Contact" mode="read" allowcolumnreordering="false" uniqueid="sk-1OB6y--95" emptysearchbehavior="query">
<fields>
<field id="FirstName" hideable="false" allowordering="true" uniqueid="fi-1OB672-373" valuehalign="" type="" showbydefault="false"/>
<field id="LastName" hideable="false" allowordering="true" uniqueid="fi-1OB672-374" valuehalign="" type="" showbydefault="false"/>
<field id="CreatedDate" hideable="false" allowordering="true" uniqueid="fi-1OB672-375" valuehalign="" type="" showbydefault="false"/>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="massupdate"/>
<action type="massdelete"/>
</massactions>
<views>
<view type="standard"/>
</views>
<searchfields/>
<actions defaultlabel="Global Actions" defaulticon="sk-icon-magic" usefirstitemasdefault="true">
<action type="multi" label="New Contact from Search" icon="sk-icon-add">
<actions>
<action type="emptyModelData">
<models>
<model>NewContact</model>
</models>
</action>
<action type="custom" datasource="salesforce" snippet="getSearchBoxValue"/>
<action type="showPopup">
<popup title="New Contact" width="50%">
<components>
<pagetitle model="NewContact" uniqueid="sk-1OHuBZ-465">
<maintitle>
<template>{{Name}}</template>
</maintitle>
<subtitle>
<template>{{Model.label}}</template>
</subtitle>
<actions>
<action type="multi" label="Save" icon="sk-icon-save">
<actions>
<action type="blockUI" message="Saving new contact..."/>
<action type="save">
<models>
<model>NewContact</model>
</models>
<onerroractions>
<action type="blockUI" message="There was an error" timeout="3000"/>
<action type="unblockUI" message="There was an error" timeout="3000"/>
</onerroractions>
</action>
<action type="closeTopmostPopup"/>
<action type="unblockUI"/>
</actions>
</action>
<action type="multi" label="Cancel" icon="sk-icon-cancel">
<actions>
<action type="cancel">
<models>
<model>NewContact</model>
</models>
</action>
<action type="closeTopmostPopup"/>
</actions>
</action>
</actions>
</pagetitle>
<basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="NewContact" buttonposition="" uniqueid="sk-1OHvCW-469" mode="edit">
<columns>
<column width="100%">
<sections>
<section title="Section A" collapsible="no" showheader="false">
<fields>
<field id="FirstName" uniqueid="fi-1OIZlS-511"/>
<field id="LastName" uniqueid="fi-1OIZlS-512"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
</popup>
</action>
</actions>
</action>
</actions>
</skootable>
</components>
<resources>
<labels/>
<css/>
<javascript>
<jsitem location="inlinesnippet" name="getSearchBoxValue" cachelocation="false">var params = argumentsu0],
$ = skuid.$;
//get contact model
var contacmodel=skuid.model.map().Contact;
//get newcontact model
var newcontactmodel=skuid.model.map().NewContact;
newcontactmodel.createRow({
additionalConditions: i{
field: 'LastName', value : skuid.model.map().Contact.conditionsi0].value
}]
});
</jsitem>
</javascript>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>
I will give that a try soon. Thanks for the help on this!!
I also wanted to default the table search value from another model. I tried set the condition ‘_default_search’ to a value. The condition is only available when a search is being made on the table though. When user types something into the search field, I want to conditionally render a global action. I use a return snippet rendering condition that checks if the conditionsi0] has a value. The snippet does not appear to be called when user types something into the search field.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.