What is the best way to have a lookup that supports creating a new record if one isn't found?

Peter, this is not the first time the idea has emerged. It would be possible to create a custom renderer that added the capabilities of allowing a popup to open where a new relatedrecord was created, but also added the lookup relationship in the original location.  And you are right - once created once, it should be abstracted so that it is available by configuration for any lookup field.   We’ll consider this an idea for future development.  

Any others out there that would appreciate this feature? 

Yep, this would be a great standard feature. I vote infinity times.

This is built into other UI’s. Access has a “not in list” event when you enter an item that is not in the list.  In some ways it ends up being a problem… the user types something in a little differently… its not found… they create a new item… and you have a duplicate entry… so usually i want the user to have to slow down enough to create a new item in the picklist so that its not automatic… but it would be a nice feature.

I will vote for this idea!  This has been a huge headache for our customers within native SF and we always get a request to make this easier. I know there are work arounds using Visualforce and Apex, but having this built into Skuid would be awesome. 

Peter, see you’re in Berkeley. Want to get together sometime ? I’m ken@8thfold.com

I can imagine a way to use the new (Skuid Winter '15) action functions to have a button near the lookup field that shows a popup/drawer, which when saved creates a new record AND then populates the lookup field. Will that work? Is there an even better way now?

Peter,

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! 




David,  this is a very intriguing solution.  Thanks for sharing

So, with the new Action framework, shouldn’t there be a way to do this now? I can easily make a popup screen that saves a new record in one of my models, but I can’t seem to figure how to get the ID of that new record to go into the lookup field of a record that is already in use on another model on my page. I don’t seem to have that option available to me in Actions.

Hi Peter, we got this working by using ‘newAccount’ and ‘newContact’ models (in addition to our ‘enquiry’ model on the page.

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



 

Ahh, thanks. The key was getting the right merge syntax as a value in a “update field on row” action. It works!

I’m working on another idea not documented here, wondering if anyone else has gotten to work:

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…

Got it working! 



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. 

Thanks Jack.  This is a great implementation. I’ll definitely be playing around with this in days to come. 

One issue I’ve found after using this in production is that you HAVE to choose a value in order to close the pop up window. And once you’ve chosen a value, there’s no way to clear the field. I tried creating a Global Action in the table that would enter a blank value in the field, save the model, then close the popup, but it just doesn’t work, it never closes the popup. I even tried Redirect to Url so that it would refresh the page but it just hangs. 

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. 

@Skuid Support Team @Rob Hatch
Any update on this skuid enhancement ?

@Skuid Support Team @Rob Hatch

Rob - Has this enhancement ever been implemented?

Thank you Jack, your solution fit my need simply and exactly!

I didn’t even know you could vote that many times. Do I second this vote? Or do I infinity +1 it? [ edited because spelling ]

Hi Jack, maybe you have tried this and could point me in right direction.

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?