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

Showing current logged in user’s profile picture next to Welcome Menu in SharePoint 2013


Hi,

We recently got a requirement to show the logged in user’s profile picture along with the name on the Welcome Menu on the top right.

We followed these steps to implement it.

  1. Open the master page used by the Site (Site Settings àMaster Pages and page layouts à Select the master page file à right click and download a copy.
  2. Add the following tags in the master page.

<%@
Register
Tagprefix=”SPSWC”
Namespace=”Microsoft.SharePoint.Portal.WebControls”
Assembly=”Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”
%>

<SPSWC:ProfilePropertyLoader
runat=”server”
/>

<SPSWC:ProfilePropertyImage
PropertyName=”PictureUrl”
style=”float: left; height: 20px;
ShowPlaceholder=”true”
id=”PictureUrlImage”
runat=”server”/>

Saving and uploading the master page.

Hope it helps.

Using SharePoint CSOM (Client Side Object Model) in CRM 2011 On-Premise Plugin.


Hi,

We recently had a requirement to create List Item in SharePoint every time a case is resolved in CRM.

For this we decided to use SharePoint CSOM i.e.

Added reference to following assemblies in our plugin that will fire on Case Resolution

They can be found at

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\

The plugin gets the content of the KB Article associated to the Case and creates a list item (for a Custom List) in SharePoint.

Sample Code


public void Execute(IServiceProvider serviceProvider)
 {
 IPluginExecutionContext context =
 (IPluginExecutionContext) serviceProvider.GetService(typeof (IPluginExecutionContext));
 if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
 {

Entity entity = (Entity) context.InputParameters["Target"];

OptionSetValue serviceStage = (OptionSetValue) (entity.Attributes["statecode"]);
 if (serviceStage.Value == 1)
 {

IOrganizationServiceFactory serviceFactory =
 (IOrganizationServiceFactory)
 serviceProvider.GetService(typeof (IOrganizationServiceFactory));

IOrganizationService orgService = serviceFactory.CreateOrganizationService(context.UserId);

// Get the KB Article Associated
 ColumnSet cols = new ColumnSet();
 cols.AddColumn("kbarticleid");

// Get the content of the article
 Entity caseEntity = orgService.Retrieve("incident", context.PrimaryEntityId, cols);
 EntityReference entityRef = (EntityReference) caseEntity.Attributes["kbarticleid"];
 Guid kbId = entityRef.Id;
 Entity kbEntity = orgService.Retrieve("kbarticle", kbId, new ColumnSet(true));
 string title = kbEntity.Attributes["title"].ToString();
 string content = kbEntity.Attributes["content"].ToString();
 // create the custom list item in SharePoint using Client Side Object Model of SharePoint 2013

ClientContext clientContext = new ClientContext("http://sharepoint/sites/portal/");
 clientContext.Credentials = new System.Net.NetworkCredential("username", "password", "mydomain");
 List announcementsList = clientContext.Web.Lists.GetByTitle("Kb List");

ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
 ListItem newItem = announcementsList.AddItem(itemCreateInfo);
 newItem["Title"] = title;
 newItem["Content"] = content;

newItem.Update();

clientContext.ExecuteQuery();

}
 }
 }

Hope it helps.

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!