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

Update: boxed view with one column only


Worked like a charm.

Christophe's avatarPath to SharePoint... and Beyond!

Last year, I published a sample script that changes the layout of boxed views from two columns to a single column.

Several readers reported that it didn’t work for them. Larry Pfaff investigated the issue, and came up with the following update:

To include the script in your page, use a CEWP placed below the boxed view.

The above script is written for wss v3. It identifies the Web Part by its id “WebPartWPQ1”. If you use MOSS, or if the boxed view is on a page along with other Web Parts (typically on the site home page), you’ll need to change the id to “WebPartWPQ2” or “WebPartWPQn“. Or you can modify the code to scroll through all the Web Parts on the page and grab the boxed views.

Larry’s update works for all boxed styles, while my initial code only worked against the “Boxed, no labels” style.

Remember that the…

View original post 170 more words

Changing font color of a column in jqGrid.


Hi,

We had a requirement to change the font color of a particular column in jqGrid. We achieved it in the following manner.

Using the formatter property


The fontColorFormat function


function fontColorFormat(cellvalue, options, rowObject) {
 var color = "blue";
 var cellHtml = "<span style='color:" + color + "' originalValue='" + cellvalue + "'>" + cellvalue + "</span>";
 return cellHtml;
 }

Hope it helps!

Implementing Marking Item as Read functionality for list item in SharePoint 2013.


Hi,

We recently had a requirement where we wanted to mark list item as read when they are opened (DispForm.aspx).

For this we added a Yes/No (checkbox) field to the List.

Opened the DispForm.aspx for editing and added a Content Editor web part there.

Uploaded a text file having following script in one of the document libraries.

</pre>
_spBodyOnLoadFunctionNames.push("updateListItem");

function updateListItem() {

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

 JSRequest.EnsureSetup();

//Get a query string parameter called Id. i.e - "page.aspx?Id=11" will return 11
 var itemId = JSRequest.QueryString["ID"];
 this.oListItem = oList.getItemById(itemId);
 oListItem.set_item('MarkAsRead', true);
 oListItem.update();

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

function onQuerySucceeded() {
 alert('Item updated!');
 }

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

And refered that txt file in our content web editor web part.

Hope it helps.

Manage New Icon Indicator for list items (DaysToShowNewIndicator) in SharePoint.


Hi,

Was looking into how long the new icon appears for a newly created list items in SharePoint.

The default is 2 days.

And this is configurable through DaysToShowNewIndicator property.

Powershell

http://www.deliveron.com/blog/post/Change-Settings-for-e2809cNewe2809d-Icon-in-SharePoint-2010-using-PowerShell.aspx

STSADM

http://technet.microsoft.com/en-us/library/cc287681(v=office.12).aspx

Programmatically

http://code-journey.com/2009/change-how-long-a-listitem-is-considered-a-new-item-setpropery-daystoshownewindicator/

Hope it helps.