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.

Dynamics CRM 2013 Links


Donna Edwards's avatarDonna Edwards

The long awaited Dynamics CRM 2013 product is available Online and for OnPremise installations.  Microsoft did a great job with the product and I’m sure you’ll appreciate the many improvements and additions to the product.  Here are the links:

Microsoft Dynamics CRM Server 2013 (Online)

Microsoft Dynamics CRM Server 2013 (OnPremise)

Microsoft Dynamics CRM 2013 for Microsoft Office Outlook (Outlook Client)

Check out my Microsoft Curah article for the latest download updates.

In addition Microsoft Dynamics CRM 2011 Update Rollup 15 is also available.   As with any update rollup, read through the list of fixed items and determine if any address issues you are experiencing.  Install the Update Rollup in a development environment first, test it for a couple of weeks and then roll it into production.

Cheers

View original post

Mark Complete an Activity on create through Plugin in CRM 2011.


Hi,

We had a requirement to immediately close the Appointment record as completed after creating it. The initial thought was to call Set State Request on the Post Create plugin. That approach gave error. Then we tried passing statecode and statuscode value as input parameter in Pre Plugin. That approach also didn’t work.

Finally we registered a pre update plugin on appointment entity and set the values for statecode and statuscode attributes. This worked for us.

The learning is that on create of Appointment record, update message is also called.

Sample Code (Pre Update)

Hope it helps.

Curious Case of Remove button for QueueItem SubGrid in CRM 2011


Hi,

The QueueItem subgrid will normally have a Remove button associated to it in the ribbon.

However when used in a view in Dashboard it goes missing.

One option to get it back is create a new custom ribbon button with the exact definition of the existing OOB Remove button.

http://www.mscrm-developer.com/2012/11/remove-button-missing-for-queue-items/

Hope it helps

Understanding Queues and QueueItem in CRM 2011


Hi,

I am currently working on a project that deals with queue management and the following posts were of immense help

http://xrmcubed.com/admin-101-queues-part1/

http://xrmcubed.com/admin-101-queues-part2/

http://xrmcubed.com/admin-101-queues-part3/

Thanks to the author !

Completed my 6 years of blogging.


Today I was surprised to see the following notification on my blog

It was 6 years back on this exact date I had created this blog on WordPress. Had never imagined would have these many hits on it.

I hope it would have helped at least few of them who visited.

Bye.