SPLookupAddNew - SP 2010: caveat trick and Emerson Bruce fix

Apr 16, 2011 at 11:51 AM


Thanks for your fantastic work,

I'm implementing SPLookupAddNew script in SP 2010 Standard Edition in a multilookup field into EditForm,

I've tried the Caveat trick disabling popup function and the Emerson Bruce (GeishaMX) Fix.

My problem is:

- disabling popup I can create the new item into the "lookup List" but coming back to the original Form all edited fields aren't saved.

- using Emerson Bruce Fix the original Form save the fields I've edited, but the new Item doesn't appear into the multilookup field (into the EditForm)


Any suggestion?

Many thanks!


jquery version: 1.5.2

SPservices: 0.6.1

Apr 16, 2011 at 7:53 PM

This is the expected behavior of the function. When you load the form for the new entry into the lookup list there's a physical post back to the other form. When the user is directed to the new form, any data already inputted into the original form will need to be re-entered. You may be able to write some custom script to save a cookie with the current form information, and a loader to read that cookie and re-populate the form, but that's not a native component of SPServices.

Apr 16, 2011 at 8:32 PM
Many people have asked me to make SPLookupAddNew work so that the original form is saved before being sent to add the new lookup value. If you think about the infinite variability which is possible, between the placement of the lookup column in the form as well as the number of potential required columns, hopefully you can see that it's virtually an impossible task.

I wrote SPLookupAddNew primarily to assist me with my testing of SPCascadeDropdowns, not really thinking that it would get the widespread use it has. You can, of course, extend it in any way you'd like to meet your specific requirements.

Apr 16, 2011 at 11:52 PM

I have been successful in using a dialog box to add new items but it took a lot of effort to create a form to do this. I am just throwing it out there as an option. It allows the addition of the item without leaving the original form and will also update the lookup with the new value. I am sorry I do not have the code with me to post, but I am actually working on a blog post for this that I hope to have up in a few days.

Apr 17, 2011 at 1:49 PM

Thank you for your quick replies.

If I find a solution to my requirement I'll be glad to post it. Spevilgenius, let me know if you post in your blog.

Apr 17, 2011 at 6:53 PM

There's two different approaches as I see them:

  1. Inject PreSaveAction with your own method to save a cookie of all of the current form values before sending the user off to the new form (there's a pretty handy jQuery cookie plugin that works well). You'd then need to write some sort of an onload event for the form to populate those values back in if a cookie exists, then clear the cookie (so it doesn't end up loading that same data next time).
  2. spevilgenius' approach of using a dialog and your own form. With 2010 you can use the SPModal API to push your own content into the native SharePoint modal windows, so you don't have to come up with your own script to create a modal dialog (for the many 2007 users, the BlockUI jQuery plugin is also very simple to use). You should be able to create a pretty simple single field form that loads into your dialog and adds the new entry to the lookup list using SPServices. You'd then need to query everything in that lookup list and re-write the options in the dropdown. This should be a relatively simple web service call also.

As Marc said, there's just so many possible permutations that this type of functionality would be very difficult to build into SPServices. Fortunately you're running 2010, so creating a modal dialog takes nothing more than a single line Javascript reference (with some options).

Aug 31, 2011 at 2:12 PM

Still need code to make this happen?

Aug 31, 2011 at 3:22 PM

Hi eruka,

Personally I don't need the code anymore (I moved the client to another solution) but maybe someone will need it!


Feb 13, 2012 at 12:29 PM



I currently encounter the same problematic, can you help me ?