Currently I'm showing the Upload Document screen in a modal so my users can upload a document to a Document Library.

The URL I'm calling to display that modal is this:


I would really prefer to not use a GUID here because when migrating from dev->testing->production the GUIDs will all change (or so I understand).

Is there a way to accomplish the same thing without using the GUID?

How do people normally handle this issue?

The only thing I can think of is somehow querying for the List GUID based on its name, but this seems like overkill & I haven't been able to find a way to do it, searching yields a bunch of questions about getting the document's GUID, but I need the Document Library's.

  • Dynamically generate the URL by getting the List ID May 20, 2015 at 17:32
  • How do I get the list ID?
    – eddie_cat
    May 20, 2015 at 17:34
  • How are you forming the link? May 20, 2015 at 17:34
  • I have a JS function for uploading docs that takes a list GUID as a parameter and I'm just appending it to that URL. I don't want to have to pass in a hard-coded GUID when I call that function.
    – eddie_cat
    May 20, 2015 at 17:37

2 Answers 2


Using JavaScript you can get ID using

var list;
ExecuteOrDelayUntilScriptLoaded(Start, "sp.js");

function Start() {
    var currentcontext = new SP.ClientContext.get_current();
    list = currentcontext.get_web().get_lists().getByTitle('ListTitle');
    currentcontext.load(list, 'Id');
    currentcontext.executeQueryAsync(Function.createDelegate(this, OnSuccess), Function.createDelegate(this, onFailed));

function OnSuccess() {

function onFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

I think that depends a lot on how your project is structured and your deployment process.

In scenarios like this, I use feature activation code to provision my document library with a GUID generated by the Visual Studio tool. Then in my code I reference this GUID where necessary. Then once the feature is packaged, deployed, and activated, it is consistent across environments.

  • I'm not really sure what you mean as I am new to SharePoint, but thanks for giving me something to look into. I was advised that I'm not allowed to activate features and have been doing everything in JS/SharePoint Designer thus far. Not sure if that makes a difference here or not.
    – eddie_cat
    May 20, 2015 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.