Autocomplete using list url

Forums Autocomplete Autocomplete using list url

Tagged: 

Viewing 4 reply threads
  • Author
    Posts
    • #16298
      Andreas Blüher
      Participant

      Hello,

      I was wondering if you got any plans to support the usage of url (aka rootfolder name of the list) like you do for vLookup? We’re working on a multilingual application with site collections in different languages and want to pre define the configuration.

    • #16497
      Alexander Bautz
      Keymaster

      Hi,
      Sorry, this one slipped past me. I’ll see if I can get this added, but in the meantime you can use the GUID – if your sites are not created from templates – if so, the GUID will be generated for each site.

      Alexander

    • #16506
      Andreas Blüher
      Participant

      Hi,

      thank you for your response. We can’t use guid, because we got several SharePoint Servers (dev, test, prd) and we move configurations from one to another. Do you have some best practices regarding this kind of scenario, because even using only url in DFFS we got an external system which is referenced. Therefor we need different urls for test and prd to the external system, which is not possible right now and includes a lot of manuell changes after deploying from Test to Prod.

      Regards
      Andreas

    • #16510
      Alexander Bautz
      Keymaster

      If you are using SharePoint 2013 / 2016 you can use this function to get the GUID from the URL name of the list – please note that the URL name is case sensitive.

      function getListByRootFolder(argObj){
          jQuery.ajax({
              url:argObj.listBaseUrl+"/_api/Web/Lists?$filter=RootFolder/Name eq '"+argObj.listUrlName+"'",
              type:"GET",
              headers: { "Accept": "application/json; odata=verbose" },
              success: function (data) {
                  var r = {"success":false};
                  if(data.d.results.length > 0){
                      r = data.d.results[0];
                  }
                  if(typeof argObj.callback === "function"){
                      argObj.callback(r);
                  }
              },
              error: function (data) {
                  if(typeof argObj.callback === "function"){
                      argObj.callback("getListByRootFolder:An error occurred");
                  }
              }
          });
      }

      Use it like this:

      getListByRootFolder({
          "listBaseUrl":"/sites/your_site",
          "listUrlName":"ListNameFromURL",
          "callback":function(list){
              var GUID = list.Id;
              // Put the code you where you want to use the GUID here.
          }
      });

      Change “listBaseUrl” and “listUrlName” to match your list.

      Hope you can use this,
      Alexander

    • #16520
      Andreas Blüher
      Participant

      Hello Alexander,

      thank you very much for the code example and I can modify it for my needs and it will work out for me. I’m a colleague of Ferdi Lethen and responsible for lists without “/lists/” prefix (which apperently is possible programmatically). I can remove /lists/ from your code and it will work afterwards.

      Thank you very much

Viewing 4 reply threads
  • You must be logged in to reply to this topic.