I have created a survey list. I need to change the redirection from QstNew.aspx page to Overview.aspx.

For this purpose,I require list name to be fetched dynamically.

I can get the list GUID from the QstNew.aspx page URL.I need to get the List name from the GUID.

Can anyone give the answers...or suggest how to get the current list name using Javascript

Thanks!!

share|improve this question
up vote 4 down vote accepted

You can use the below rest call as well.:

Replace guid with your list guid.

$.ajax({
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists(guid 'b778bbec-dd69-4a6c-9437-c73972c36292')",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            console.log("List Title :" + data.d.Title);
        },
        error: function (data) {
            console.log(data);
        }
  });
share|improve this answer
    
This worked for me.!! Thanks Gautam – NivethaSri 15 hours ago

Using Client Object Model will help in this case:

var oList;

function getListTitleById() {
    var clientContext = SP.ClientContext.get_current();

    oList = clientContext.get_web().get_lists().getById(__ID of the list__);

    clientContext.load(oList,"Title");

    clientContext.executeQueryAsync(
            Function.createDelegate(this, this.onQuerySucceeded), 
            Function.createDelegate(this, this.onQueryFailed)
        );
}

function onQuerySucceeded(sender, args) {
    alert('Title: ' + this.oList.get_title());
}

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

Where oList is a global variable.

share|improve this answer
    
I need to do it using Javascript. Can you give the suggestions for doing this through javascript? @Adam – NivethaSri 18 hours ago
    
This is JSOM, meaning JavaScript Object Model for SharePoint. Do you mean without using JSOM? – Arsalan Adam Khatri 18 hours ago
    
Yes.I meant without usinh jsom @adam khatri – NivethaSri 17 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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