SPLookupAddNew not opening form in right list

Apr 24, 2010 at 2:02 PM

I have implemented both the Casading and the Addnew on a form.  Works great, except for some reason, the add new link is opening a new form in the current list, not the list from the lookup field.

Code is applied to form in PORTFOLIO list.  The lookup column on is pulling values from the PROJECT list.  This is working fine.  The Cascading list function seems to be working find.

 

But the Add new link opens a new from in the PORTFOLIO list not the PROJECT list that is being used in the lookup column.  Any ideas?

<script language="javascript" type="text/javascript" src="https://in.nokia.com/sites/WRPMODev/Script%20Library/jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript" src="https://in.nokia.com/sites/WRPMODev/Script%20Library/jquery.SPServices-0.5.4.min.js"></script>
<script language="javascript" type="text/javascript">
 $(document).ready(function() {
  $().SPServices.SPCascadeDropdowns({
            relationshipList: "Projects",
            relationshipListParentColumn: "Prg",
   relationshipListChildColumn: "Title",
   parentColumn: "Title",
   childColumn: "Components",
   debug: true
  });
  $().SPServices.SPLookupAddNew({
   lookupColumn: "Components",
   promptText: "Add new {0} "
 });

   });

Coordinator
Apr 24, 2010 at 2:54 PM

Hmm. I haven't heard of anyone else having problems, so I'm wondering what might be different in your scenario.

Let me state back to you what I think is happening, and tell me if I have it right:

  • You have two lists, PROJECT and PORTFOLIO
  • The PORTFOLIO list has a column named Components which is a Lookup column into the PROJECTS list (not sure what column)
  • You've added the jQuery above to the NewForm for PORTFOLIO
  • When you click the resulting 'Add new Components' link, the NewForm for PORTFOLIO is launched (as opposed to the expected NewForm for PROJECTS)

Is that all correct? If so, it would be really helpful for me if you could call GetList on PORTFOLIO and post back what that shows.

M.

Apr 25, 2010 at 2:33 PM

Yes your recap is correct,, except I added the code to the EditForm for PORTFOLIO.

Sorry, I am not exactly sure what how to use the GetList to return the listname value.  I am assuming I need to somehow return what the SPLookupAddNew function things the listname is being used in the lookupColumn? 

I added the following., just as a guess, but naturally it does not return anything...

$().SPServices.SPLookupAddNew({
   lookupColumn: "Components",
   promptText: "Add new {0} ",


   completefunc: function()
   {
    var id = "";
    $().SPServices({
    operation: "GetList",
    listName: listName,
    async: false,
    completefunc: function (xData, Status) {
    id = $(xData.responseXML).find("List").attr("ID");
    }
    });
    alert(id);
     }


  });

Coordinator
Apr 27, 2010 at 4:33 AM

Sorry for the delayed response and the confusing prior post.

What I'm hoping to get at is the settings for the Components column in PORTFOLIO. Here's what I meant:

 $("#divId").html(waitMessage).SPServices({
  operation: "GetList",
  listName: "PORTFOLIO",
  completefunc: function (xData, Status) {
   var out = $().SPServices.SPDebugXMLHttpResult({
    node: xData.responseXML
   });
   $("#divId").html("").append("<b>This is the output from the GetList operation:</b>" + out);
  }
 });

For this to work, you'll need to have a DIV somewhere in the page with an id of divId:

<div id="divId"></div>

In the output from this, you should be able to find the field settings for Components.

Thanks,
M.