Friday 10 January 2014

Get current list name of new-edit form using javascript

Problem Description:

While playing with JavaScript, today I require List name of current form (new, edit).
After little bit googlling i am getting some scripts but there are some bugs.
after working with that all scripts, final scripts is ready to use, as below....

var clientContext = SP.ClientContext.get_current();
oWeb = clientContext.get_web();
oListColl = oWeb.get_lists();
var currentListGUID = SP.ListOperation.Selection.getSelectedList();
var ListName="";
if (currentListGUID === null)
{
        ListName = $(".s4-titletext h2 a:first").html(); //requires JQuery to get list name from ribbon
}
else
{               
        ListName=currentListGUID;
}

That's all...!!!




No comments:

Post a Comment