4

I'm trying to figure out how I can get a list's add new item URL using JSOM in SharePoint 2010. This is what I have so far to get if the current user has edit access on the list.

ExecuteOrDelayUntilScriptLoaded(function()
{
    var clientContext = SP.ClientContext.get_current();
    var list = clientContext.get_web().get_lists().getByTitle("Shared Documents");
    clientContext.load(list);
    clientContext.load(list, 'EffectiveBasePermissions');
    clientContext.executeQueryAsync(Function.createDelegate(this, function()
    {
        if(list.get_effectiveBasePermissions().has(SP.PermissionKind.editListItems))
        {
            // has edit permissions
        }
    }), Function.createDelegate(this, function(){}));
}, "sp.js");
7

Load DefaultNewFormUrl property of the list. Example:

clientContext.load(list, 'DefaultNewFormUrl');

Then retrieve it in the success method:

var newUrl = list.get_defaultNewFormUrl();
5

I guess your are looking for SP.List.defaultNewFormUrl property (sp.js).

var value = SP.List.get_defaultNewFormUrl();

Try following

var list = clientContext.get_web().get_lists().getByTitle("Shared Documents");
var listNewForm = list.get_defaultNewFormUrl();

PS: MSDN documentation reads that

Applies to:

apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

I think it should work in SharePoint 2010 also. Try and let me know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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