Object reference not set to an instance of an object. at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaNavigationSettingsPage.OKButton_Click(Object sender, EventArgs e) error in AreaNavigationSettings.aspx page


Hi,

Was getting the above issue while trying to configure navigation for the SharePoint Site. Tried out different solutions mentioned in the following post.

http://phinotworking.com/stubborn-site-navigation-menu-items/

Corrected the JavaScript issue on the page, renamed the id of the div to something else instead of container but that didn’t work. Then through PowerShell script deleted few of the navigation links and again gave it a try. This time it worked properly.


I think the navigation page would have got corrupted or something because of those links and hence deleting those links fixed the issue.

Hope it helps.


Windows could not connect to the User Profile Service service \ Desktop is not available\ The dependency service or group failed to start errors in Windows Server 2008


Hi,

I was getting the above error after logging into the Windows Server 2008 machine. Tried out different things but nothing helped.

Finally we figured out the reason for this. Actually someone had configured the User Profile Service to run under a different credentials instead of Local System.

Running it back under the Local System account resolved the issue for us.

Hope it helps.

Disable view selector menu in ListViewWebPart in SharePoint 2013.


Hi I was facing the issue that has been mentioned in this thread

http://social.technet.microsoft.com/Forums/sharepoint/en-US/3c323f28-0b0b-410c-9a4e-3a824d923713/2013-list-view-webpart-view-selector?forum=sharepointgeneral

The view selector menu was not showing up on the custom web part page.

The way we got it working was to extend the XSLTListViewWebPart and set that property though code.


public partial class VisualWebPart1 : System.Web.UI.WebControls.WebParts.WebPart
 {
 // Uncomment the following SecurityPermission attribute only when doing Performance Profiling using
 // the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
 // for production. Because the SecurityPermission attribute bypasses the security check for callers of
 // your constructor, it's not recommended for production purposes.
 // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
 public VisualWebPart1()
 {
 }

protected override void OnInit(EventArgs e)
 {
 base.OnInit(e);
 InitializeControl();
 }
 private Microsoft.SharePoint.WebPartPages.XsltListViewWebPart myListView;

protected override void CreateChildControls()
 {
 base.CreateChildControls();
 SPSite oSiteCollection = SPContext.Current.Site;
 string listName = "Notification Centre";
 SPWeb oWebSite = SPContext.Current.Web;
 myListView = new Microsoft.SharePoint.WebPartPages.XsltListViewWebPart();
 myListView.Visible = true;
 myListView.EnableViewState = true;
 SPList list = oWebSite.Lists[listName];

myListView.ListName = list.ID.ToString("B").ToUpperInvariant();
 myListView.TitleUrl = list.DefaultViewUrl;
 myListView.WebId = list.ParentWeb.ID;

myListView.ListId = (System.Guid)list.ID;
 myListView.ViewGuid = list.DefaultView.ID.ToString("B").ToUpperInvariant();

myListView.HelpMode = WebPartHelpMode.Modeless;

myListView.DisableViewSelectorMenu = false;
 myListView.InplaceSearchEnabled = true;

myListView.AllowEdit = true;

Controls.Add(myListView);
 }

protected void Page_Load(object sender, EventArgs e)
 {
 }
 }

Hope it helps

Implementing Mark As Read and Delete functionality for selected list items in SharePoint 2013


We recently had a requirement to implement Mark As Read, Unread and Delete feature for the list items selected in the list.

User will select the list items record and can perform the required operation by selecting appropriate button.

For this we added a content editor web part having the following content


<div>
 <input type="button" value="Mark As Read" onclick="javascript:MarkRead();" />
 <input type="button" value="Mark As UnRead" onclick="javascript:MarkUnRead();" />
 <input type="button" value="Delete" onclick="javascript:Delete();" />
</div>

<script language='javascript' type='text/javascript'>

var items;
 var ctx;
 var count;
 var web;
 var totalCount = 0;

function Delete() {
 debugger;
 ctx = SP.ClientContext.get_current();
 web = ctx.get_web();
 var currentlibGuid = SP.ListOperation.Selection.getSelectedList();
 if (currentlibGuid == null) {

alert('Please select an item in the list!');
 return;
 }
 var currentLib = web.get_lists().getById(currentlibGuid);
 items = SP.ListOperation.Selection.getSelectedItems(ctx);

//Get Selected Items count
 count = CountDictionary(items);

&nbsp;

for (var i in items) {
 var currentItem = currentLib.getItemById(items[i].id);
 ctx.load(currentItem);

currentItem.deleteObject();

ctx.executeQueryAsync(
 Function.createDelegate(this, this.Succeeded),
 Function.createDelegate(this, this.onQueryFailed)
 );

}
 }

function MarkUnRead() {
 ctx = SP.ClientContext.get_current();
 web = ctx.get_web();
 var currentlibGuid = SP.ListOperation.Selection.getSelectedList();
 if (currentlibGuid == null) {

alert('Please select an item in the list!');
 return;
 }
 var currentLib = web.get_lists().getById(currentlibGuid);
 items = SP.ListOperation.Selection.getSelectedItems(ctx);

//Get Selected Items count
 count = CountDictionary(items);

&nbsp;

for (var i in items) {
 var currentItem = currentLib.getItemById(items[i].id);
 ctx.load(currentItem);

currentItem.set_item('MarkAsRead', false);
 currentItem.update();

ctx.executeQueryAsync(
 Function.createDelegate(this, this.Succeeded),
 Function.createDelegate(this, this.onQueryFailed)
 );
 }
 }
 function MarkRead() {

ctx = SP.ClientContext.get_current();
 web = ctx.get_web();
 var currentlibGuid = SP.ListOperation.Selection.getSelectedList();
 if (currentlibGuid == null) {

alert('Please select an item in the list!');
 return;
 }
 var currentLib = web.get_lists().getById(currentlibGuid);
 items = SP.ListOperation.Selection.getSelectedItems(ctx);

//Get Selected Items count
 count = CountDictionary(items);

&nbsp;

for (var i in items) {
 var currentItem = currentLib.getItemById(items[i].id);
 ctx.load(currentItem);

currentItem.set_item('MarkAsRead', true);
 currentItem.update();

ctx.executeQueryAsync(
 Function.createDelegate(this, this.Succeeded),
 Function.createDelegate(this, this.onQueryFailed)
 );
 }
 }
 function onQueryFailed(sender, args) {

totalCount = totalCount + 1;

if (totalCount == count) {
 location.reload();
 }
 alert('Request failed. ' + args.get_message() +
 '\n' + args.get_stackTrace());
 }

function Succeeded() {

totalCount = totalCount + 1;

if (totalCount == count) {
 location.reload();
 }
 }
</script>

&nbsp;

Was helped by a good friend of mine and colleague Priyanka, a SharePoint expert. You can check her insightful posts at her MSDN Blog

http://blogs.msdn.com/b/mind_talks/

Hope it helps

Message: Sys.InvalidOperationException: Type SP.IWebRequestExecutorFactory has already been registered issue in SharePont 2013.


Hi,

I was getting the above JavaScript warning message, on one of the pages. On digging deeper found out that the custom master page that we were using had the sp and sp.runtime js registered over there.

Removing it resolved the issue.

Hope it helps.

Getting Count of List Items based on a specific condition using JavaScript in SharePoint 2013


Hi,

Below is the sample script we used to get the total listitems that have MarkAsUnread ( Yes/No) Column value set as No (i.e. 0)


var myItems;

function GetCount() {
 debugger;
 var queryListItem = '<View><Query><Where><Eq><FieldRef Name="MarkAsRead" /><Value Type="Boolean">0</Value></Eq></Where></Query></View>';

 var siteUrl = window.location.protocol + "//" + window.location.host;
 var clientContext = new SP.ClientContext(siteUrl);
 var oList = clientContext.get_web().get_lists().getByTitle('Notification Centre');

var myquery = new SP.CamlQuery();
 myquery.set_viewXml(queryListItem);
 myItems = oList.getItems(myquery);

clientContext.load(myItems);

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

function onQuerySucceeded(sender, args) {

alert(myItems.get_count());
}

function onQueryFailed(sender, args) {

 alert('Request failed. ' + args.get_message() +'\n' + args.get_stackTrace());
}

Hope it helps