SPLookupAddNew: Lookup to another site

Mar 17, 2010 at 11:31 PM

Thank you very much for this function. I have used it and like it very much.  

Is there any way now, or could a future enhancement be, to get lookup information form anther site?I use some codeplex custom field controls such as http://filteredlookup.codeplex.com/ to get lookup data from another site. I tried to use the function with the SPLookupAddNew: function but it will not work.

Does the function only recognize the default lookup field type?

Love it – keep up the excellent work.

 Tenorman

Coordinator
Mar 18, 2010 at 3:18 AM

You can have your Lookup columns reference data in other sites if you set up the Lookup column as a Site Column.  Generally, I create the Site Columns in the root site so that they are available to the entire Site Collection.  (Think about my examples of Countries and States. These values don't, nor should they, vary across the Site Collection.)

That said, my library relies on the specific markup in the DOM that SharePoint renders for each column type.  Lookup columns have very specific control structures that the jQuery needs to be able to find for SPCascadeDropdowns to work.  If you are using custom field controls like the one you linked to, I'm guessing that the rendering isn't going to match SharePoint's, so SPCascadeDropdowns isn't going to work.

M.

Mar 18, 2010 at 5:12 AM
Edited Mar 18, 2010 at 3:44 PM

Marc,

 

 You are right I should create a site column and stick with the regular look up.  I will try it tomorrow.   I was using the filter part of the custom field control but it is not essential for what I am doing.  Is there a way to just filter a lookup with the Jqeury Library? The filter portion of the cascading drop down function is awesome. If that was a standalone function it would be great

 

Thanks,

 

 

 

From: sympmarc [mailto:notifications@codeplex.com]
Sent: Wednesday, March 17, 2010 10:18 PM
To: peter@greatstone.com
Subject: Re: SPLookupAddNew: Lookup to another site [SPServices:205320]

 

From: sympmarc

You can have your Lookup columns reference data in other sites if you set up the Lookup column as a Site Column. Generally, I create the Site Columns in the root site so that they are available to the entire Site Collection. (Think about my examples of Countries and States. These values don't, nor should they, vary across the Site Collection.)

That said, my library relies on the specific markup in the DOM that SharePoint renders for each column type. Lookup columns have very specific control structures that the jQuery needs to be able to find for SPCascadeDropdowns to work. If you are using custom field controls like the one you linked to, I'm guessing that the rendering isn't going to match SharePoint's, so SPCascadeDropdowns isn't going to work.

M.

Read the full discussion online.

To add a post to this discussion, reply to this email (SPServices@discussions.codeplex.com)

To start a new discussion for this project, email SPServices@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Mar 18, 2010 at 4:02 PM
Edited Mar 18, 2010 at 4:31 PM

Hi Marc,

 I moved my source list in the root level and created a site column for the look up.  I am using the SPLookupAddNew: in  a subsite one level down.  It looks like the function expects the  lookup list to be in the same site as the function call..

My look up list is located here. http://companyweb/Lists/Properties

My newform with the function is located here http://companyweb/mdcprojects/Lists/Projects/NewFormCustom.aspx

 Unless I am missing a parameter in my set up, when I click the link to add the new record to the lookup, the function looks for the list in the same site. Here is the link

 http://lists/Properties/NewForm.aspx?Source=http://companyweb/mdcprojects/Lists/Projects/NewFormCustom.aspx?etc...

 For now I am going to move my list in the same site but it is not my ideal location for it.

 It would be a great enhancement to get data from any lookup in the site collection. of course it is very useful as it is now too.

Thank you,

 Tenorman

Coordinator
Mar 18, 2010 at 4:09 PM

Tenorman:

The function should find the list that the Lookup column refers to wherever it is.  I do this by looking into the settings for the column in the current list (in your case http://companyweb/clientprojects/Lists/Projects).

What looks like it is missing is the server name in the resulting link: http://lists/Properties/NewForm.aspx?Source=http://companyweb/mdcprojects/Lists/Projects/NewFormCustom.aspx

It should be: http://companyweb/lists/Properties/NewForm.aspx?Source=http://companyweb/mdcprojects/Lists/Projects/NewFormCustom.aspx.  Right?

Can you paste in the code you're using?

M.

Mar 18, 2010 at 4:25 PM
Edited Mar 18, 2010 at 4:33 PM

Marc,

Here is my code from my http://companyweb/mdcprojects/Lists/Projects/NewFormCustom.aspx

<script language="javascript" type="text/javascript" src="http://companyweb/JqueryLib/jquery.js"></script>
<script language="javascript" type="text/javascript" src="http://companyweb/JqueryLib/jquery.SPServices-Latest.min.js"></script>
<script language="javascript" type="text/javascript">
        $(document).ready(function() {
                $().SPServices.SPLookupAddNew({ 
                    lookupColumn: "ProjectProperty",
                    promptText: "Add new {0} ",
                   debug: true
                });
        });
</script>

Tenorman

Mar 18, 2010 at 4:29 PM

" It should be: http://companyweb/lists/Properties/NewForm.aspx?Source=http://companyweb/mdcprojects/Lists/Projects/NewFormCustom.aspx.  Right?"

Yes you are right

 

Mar 18, 2010 at 4:33 PM

In my earleir post where I had "clientprojects" it is actually mdcprojects

Coordinator
Mar 18, 2010 at 4:33 PM

OK, looks right, assuming that:

jquery.js = 1.3.2+
jquery.SPServices-Latest.min.js = v0.5.2

and ProjectProperty is a Lookup column which takes it' values from a column in the list http://companyweb/lists/Properties

M.

Mar 18, 2010 at 4:40 PM

jquery.js = 1.3.2+    Correct
jquery.SPServices-Latest.min.js = v0.5.2     I have 0.5.0   I will upgrade and try again.  I should have done that first.

Mar 18, 2010 at 4:59 PM

OK

I upgraded to jquery-1.4.2.min.js  and jquery.SPServices-0.5.2.min.js   I use the generic names so I don't have to edit each form I use the functions in..   I still have issue where the same issue where "companyweb" is absent

http://lists/Properties/NewForm.aspx?Source=http://companyweb/mdcprojects/Lists/Projects/NewFormCustom.aspx?RootFolder=%2Fmdcprojects%2FLists%2FProjects%26ContentTypeId=0x01009C60CEB78FBE71438E3065A0DA5FBEEB00B08D8D89EB86744E937416D55CBD0414%26Source=http%3A%2F%2Fcompanyweb%2Fmdcprojects%2FLists%2FProjects%2FAllItems%2Easpx

I am going to try on another server where i am not using the defualt "companyweb" name.

I will get back to you.

Thanks for your time.

Tenorman.

Mar 18, 2010 at 7:20 PM

Marc.

 I tried it on another server and could not replicate the problem. I created a site column look up in the root and used this function successfully on a sub site. It is a server that has a Domain name rather then “companyweb”.    I am kind of stumped on the first server.  I was double checking my alternate access mappings and  managed paths but I see no issue there. 

I don’t need to click on the URL all I need to do is hover over it to see it is missing the servername.   The link does correctly have the source correct.

Can tell me how the server name is identified in the function? That might give me a clue. Perhaps it is the way companyweb was initially set up on this particular server.

Thanks for your time.

Tenorman 

Coordinator
Mar 18, 2010 at 7:40 PM

I started to write up how the function works, but I remembered that the basic outline is on the doc page:

http://spservices.codeplex.com/wikipage?title=%24%28%29.SPServices.SPLookupAddNew

M.

Mar 18, 2010 at 7:56 PM

 Is there a preferred method for me to isolate and run  getlist and GetFormCollection web services? 

I appreciate your time on this.

Coordinator
Mar 18, 2010 at 7:59 PM

Here are two functions I use to test them.  You'll need to add a DIV to the page with an Id, which you'd replace divId with below.

function callGetList() {
 $(divId).html(waitMessage).SPServices({
  operation: "GetList",
  listName: "Regions",
  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);
  }
 });
}

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