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

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?

Can you post some screenshots of how you’ve set up the row action and/or your page xml?

Sure , my current actions are pretty simple:

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


One problem is that in your popup, your table has a model of Lenders, but your action updates the row(s) on a different model, NewSubmissions2, so that’s why it’s updating all rows with your Lender Id.

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. 

obviously table context won’t help, since NewSubmission is a new record, there won’t be any Lenders associated with it! so, ignore that. 

ya I had tried that thinking the same way u did… to no avail :frowning:

but ty for your efforts in trying to help me

Ok got it -
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

Ty I will try it shortly, but if u could post your prototype, i’m sure it will make it much easier for me to visualize it.

Thx again!

Jack you are a genius!

Thank you very much , it worked like a charm!

Glad it worked Dave! Here’s the page xml for my test page using Contacts and Accounts:

New Contacts with existing or new Accounts


One thing that isn’t ideal, if you choose a contact for which you’ve already chosen an account, click the row action to open the popup of accounts, and then close the popup without choosing an account, it will clear out the account value on that contact. So you might do something like use the myns component to disable the x button on the popup window if you find that to be a problem. 

Dave, I know this was two years ago, so you may be doing something totally different now, but I think I finally have enough Skuid knowledge to understand your solution and find it totally amazing. One question I have is, how do know which models to save when you say “Save Models in Context”, if you have this button as an item in your custom header on all pages?

I guess this was before Master Pages and the Navigation component, so maybe you just built the same page title as a header over and over on every page, so you could choose the models to save.

Is there some way to have a button action that looks at all the models that exist in that context and save them, without having to explicitly declare model names?

Good catch, I see what u mean and could be a little issue.

What is that myns component you are mentioning?


the genius of Barry Schnell: http://community.skuid.com/skuid/topics/popup-controller-component-disable-x-escape-key-and-hook-di…

A lot of what he did got incorporate in the After-Close Actions now available on popups, but the disable X button is still pretty useful