What is the best way to have a lookup that supports creating a new record if one isn't found?
In my experience, one of the biggest annoyances for standard SF users is that when they use a lookup field to try to find a record, but don't find one, they can't create a new record right then - they have to click out of the lookup, go to another place, create a new record, then come back and use the lookup field again.
With Skuid, I know I can build a better lookup field (as a picklist or a type-ahead search), but what is the best way to allow a user to say "I didn't find one, so create a new one and put it in the lookup/search field"? I can easily put a button near the lookup field that functions as a popup in which to create the new record, but the user still has to save, close the popup, and re-search for that record again in the lookup field. Is there a simple way to put that record into the right lookup field right away on the editor I came from? Or do I have to use javascript to do this?
Better yet, I'd love to see this built-in, such as a config option on lookup fields for 'Show "Create New" option' with a pop-up field configuration. When selected, it would automatically pop up a page/editor and fill the field with the new record's ID when it is saved (and close the popup).
With Skuid, I know I can build a better lookup field (as a picklist or a type-ahead search), but what is the best way to allow a user to say "I didn't find one, so create a new one and put it in the lookup/search field"? I can easily put a button near the lookup field that functions as a popup in which to create the new record, but the user still has to save, close the popup, and re-search for that record again in the lookup field. Is there a simple way to put that record into the right lookup field right away on the editor I came from? Or do I have to use javascript to do this?
Better yet, I'd love to see this built-in, such as a config option on lookup fields for 'Show "Create New" option' with a pop-up field configuration. When selected, it would automatically pop up a page/editor and fill the field with the new record's ID when it is saved (and close the popup).
Tagged:
8
Categories
- 7.9K Questions
- 926 Ideas
- 220 Discussion Categories
- 178 General
- 9 Community Feedback
- 3 Community Info
- 18 Knowledge Base
Comments
Any others out there that would appreciate this feature?
We had the same challenge and for now we came up with a unique way around this that works well and is very easy to build.
1. Take your exisitng list view pages for all your lists and clone them all and create new pages (rename the model names) Clean up your tables to only show necessary columns needed for creating a new record (required fields).
- Only show 5 rows on the list view tables and load 5 records max (loads very quick)
2. Create a new page (Name something like "SearchAddPage" that will be a tabbed page with page includes with your new list view pages - use a drop down tab component to select your page includes to make it look nice.
3. Use a Page Title component and drop a new button in it linked to multiple actions on all pages needed. (We have a custom nav bar so it is at the top of all pages)
Button Actions:
- Save models in context (In case user navigates away from page accidentally)
- Launch Popup - Link to the new page you created (SearchAddPage)
- Add a Page Title and "Close" button on popup (Close top most popup)
Now the user can be on any page and have a button that will popup a drop down menu that will have all your lists views so they can search or add records. If they are working on a record and the field in context is a lookup to a Contact, and they realize that the contact does not exist; they can click the new Search / Add button and add the contact and it will be available when they close the popup to lookup and add.
Work around but it is working well for our users!
When the user chooses to add a new Account and/or Contact, we have a button which:
- Saves the enquiry model
- creates a new row in the newAccount model
- creates a new row in the newContact model (with a condition of AccountId = Id from the newAccount model
- shows a popup which allows the user to enter the new account/contact info.
That popup then has a 'Save & Close' button, which runs multiple actions:
- Saves both the newAccount & newContact models
- updates the Account field on our 'enquiry' model with {{$Model.newAccount.data.0.Id}}
- updates the Contact field on our 'enquiry' model with {{$Model.newContact.data.0.Id}}
- Closes the popup
here's a screenshot of the Save & Close popup in the page builder. Hope this helps
Add the lookup field to a Template field, then customize the popup window using some of the above tricks. I've got it sort of working, when I get the bugs out I'll post back, unless someone else has done this bug free and wants to share the code...
So we have a Loan Officer field on Opportunity that looks up to a Contact. Our NewLoanOfficer model pulls from all contacts on the Account model, which is the one Account over the Opportunity. So, you'll need to find some way to limit the lookup field's model.
I included the LoanOfficer lookup field (in double brackets) on a Template Field in my Opportunity Field Editor. Then, I selected Show Custom Popup for edit mode behavior.
The custom popup includes a table with my NewLoanOfficer model, allowing inline record creation, showing save/cancel.
Note: I don't have a search box in the image because it gave me all sorts of trouble at first, but after getting everything else working, search works great now too.
I removed all default actions, and adding a Row Action that runs multiple actions.
The row action is called "Select this Loan Officer".
First it saves the model NewLoanOfficer, in case you just created a new one or edited any existing ones. (Whatever you set the table to, it will always open in Edit mode, I guess that's being forced since the pop-up loads from editing the template field.)
Next it updates the LoanOfficer field on Opportunity with {{{Id}}} triple brackets to include the selected value.
Then it saves Opportunity model, and querys it to replace the field value with the chosen Loan Office, then it closes the popup. I had some trouble with choosing close the topmost popup, but it worked with close all popups.
My current solution - I added some template text "Note: You must choose a Loan Officer" that renders conditionally if the field is blank.
Once the field is populated, you can open that edit window and close it without choosing a new value.
Any update on this skuid enhancement ?
Rob - Has this enhancement ever been implemented?
I needed to implement same as your idea but this time on a table. So instead of using a Template field I used same idea , but used a Row Action
But now the issue i'm facing is that it updates all the rows , not only the Row I Selected action from.
Any idea?
I have a table for model named NewSubmissions2:
From this table i create new submissions(often multiple) + before even saving it, I click action that just opens a popup with table of model "lenders".
In that table I added action to update field on row and insert {{{ID}}} + close topmost popup
The reason I do not save first as you suggested, is because of different validation rules , including one that the lender's name cannot be blank...
Writing this i realize that may be part of the issue, as prob would need an ID to pass to lookup, so it knows which row to update?
I could always have an action enter fictitious data to bypass validation, and then have them overwritten with proper values from lender table, but still am not sure how it would update each rows with proper selection
Hope it's not too confusing
Thx
Do you have context condition set on your Lender table in the popup, for Id = Lender__c of row in context? Not sure that will help
In my example I was using a detail page, only had one opportunity to deal with. But with your table of unsaved NewSubmissions it's a little trickier. I'll play around and see if I can figure it out.
but ty for your efforts in trying to help me
Add a new model for SingleLender, clone your Lenders model, but uncheck load on page load
your row action on New Submissions opens the popup like you have it
The popup has your table of Lenders. Your row action for each lender does the following:
Adopt Rows into Model - source: Lenders destination: SingleLender
Close Popup
In the popup, add an After-close action of Update field on row just like you did before, update the NewSubmission Lender__c field, but choose Single Specified Value, then put in {{$Model.SingleLender.data.0.Id}}
Should work. On your row action to open the Lenders table, you'll also want to remove all rows from Single Lender model, so you're clearing it out each time.
And it works if you create a new lender and don't save it, but works better if you save the new Lender first, so on your close action or row action you might add a save Lenders model somewhere
I've got a prototype page if any of that is confusing
Thx again!
Thank you very much , it worked like a charm!
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Opportunity" theme="Modern"> <models>
<model id="Contacts" limit="20" query="false" createrowifnonefound="true" adapter="salesforce" type="" sobject="Contact">
<fields>
<field id="Name"/>
<field id="Id"/>
<field id="FirstName"/>
<field id="LastName"/>
<field id="AccountId"/>
<field id="Account.Name"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="Accounts" limit="20" query="true" createrowifnonefound="false" adapter="salesforce" type="" sobject="Account">
<fields>
<field id="Id"/>
<field id="Name"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="NewAccount" limit="1" query="false" createrowifnonefound="false" adapter="salesforce" type="" sobject="Account">
<fields>
<field id="Id"/>
<field id="Name"/>
</fields>
<conditions/>
<actions/>
</model>
</models>
<components>
<pagetitle uniqueid="sk-3eQKFv-312" model="Contacts">
<actions>
<action type="savecancel" label="New Button"/>
</actions>
<maintitle>New Contacts with existing or new Accounts</maintitle>
</pagetitle>
<skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Contacts" mode="edit" uniqueid="sk-3aeyot-89">
<fields>
<field id="FirstName" valuehalign="" type=""/>
<field id="LastName" valuehalign="" type=""/>
<field id="AccountId"/>
</fields>
<rowactions>
<action type="multi" label="Add Account" icon="sk-icon-employment-info">
<actions>
<action type="showPopup">
<popup title="Select Account for Contact {{Name}}" width="90%">
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Accounts" buttonposition="" mode="read" uniqueid="sk-3aider-593">
<fields>
<field id="Name" valuehalign="" type=""/>
<field id="Id"/>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
<action type="multi" label="Select This Account" icon="sk-icon-import">
<actions>
<action type="adoptRows" sourcemodel="Accounts" targetmodel="NewAccount"/>
<action type="closeTopmostPopup"/>
</actions>
</action>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="massupdate"/>
<action type="massdelete"/>
</massactions>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
<afterclose>
<action type="updateRow" fieldmodel="Contacts" field="AccountId" enclosevalueinquotes="true" value="{{$Model.NewAccount.data.0.Id}}"/>
</afterclose>
</popup>
</action>
<action type="emptyModelData">
<models>
<model>NewAccount</model>
</models>
</action>
</actions>
</action>
</rowactions>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
<resources>
<labels/>
<css/>
<javascript/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>