SharePoint solution activate button is disabled

Hi,

Today we are working on integrating CRM with SharePoint. As we all know if we need to upload list component in SharePoint and activate it. When I tried upload, observed that the Activate button is disabled even though I logged in as Admin.

The problem is that “SharePoint User Code Host” service was disabled which was of course due to the “Microsoft SharePoint Foundation Sandboxed Code Service” being Stopped (or probably in this case just never started to begin with).

To start the service, navigate to Open Central Administration–> System Settings –> Manage Services on Server and start “Microsoft SharePoint Foundation Sandboxed Code Service”.

 
Hope it helps.


Happy CRM’ing
Gopinath

Create a folder in SharePoint from CRM Plugin

Hi,
 
Today we got requirement to create a folder automatically in Share Point when a record is created in CRM. Normally SharePoint document location is created when we click on Documents on the left navigation pane for the record.
 
It can be done very easily by using the plugin but we should register the plugin None mode. It’s not applicable for Online CRM.
 
Here is the code. 

public void Execute(IServiceProvider serviceProvider)

{
      IPluginExecutionContext iContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
      IOrganizationServiceFactory iServFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
      IOrganizationService iService = iServFactory.CreateOrganizationService(iContext.UserId);
      ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
      if (iContext.InputParameters.Contains(“Target”) && iContext.InputParameters[“Target”] is Entity && iContext.MessageName.ToLower() == “create”)
      {
           Entity entAccount = (Entity)iContext.InputParameters[“Target”];
           string strSharePointURL = CreateFolderInSharePoint(iService, entAccount.Attributes[“name”].ToString(), entAccount.Id);
      }
}

public string CreateFolderInSharePoint(IOrganizationService coreCrmService, string strAccountName, Guid guidAccountId)

{
      string strDocLibraryUrl = http://SharePointURL”;
      string strApplicationFolderUrl = strDocLibraryUrl + “/” + “account”;
      string strFolderUrl = strApplicationFolderUrl + “/” + strAccountName;
      // Create folder and subfolder inside SharePoint site
      CreateFolderStructure(strApplicationFolderUrl, strFolderUrl);
      // create and associate the url of the folder to SharePointDocumentLocation and the crm record.
      CreateAndAssociateSharePointDocumentLocation(coreCrmService, guidAccountId, “account”, strFolderUrl);
      return strFolderUrl;
}

// Check and create folder.

private bool CreateFolderStructure(string strSharePointDocumentUrl, string strFolderUrl)
{
     if (CreateFolder(strSharePointDocumentUrl))
     {
          return CreateFolder(strFolderUrl);
     }
     return false;
}

// Create Folder
private bool CreateFolder(string strFolderUrl)
{
     try
     {
          WebRequest request = WebRequest.Create(strFolderUrl);
          request.UseDefaultCredentials = true;
          request.Method = “MKCOL”;
          WebResponse response = request.GetResponse();
          response.Close();
     }
     catch (Exception ex)
     {
           // throw ex;
     }
     return true;
}

// Create a Document Location record in CRM by associating Share Point URL.

public static bool CreateAndAssociateSharePointDocumentLocation(IOrganizationServiceiService, GuidguidIncidentId, string strAccount, string strSharePointDocumentUrl)
{
      Entity entSharePointDocumentLocation = new Entity(“sharepointdocumentlocation”);
      entSharePointDocumentLocation.Attributes[“name”] = “SharePoint Document Location for “ + strAccount;
      entSharePointDocumentLocation.Attributes[“description”] = “SharePoint Document Location created for storing documents related to account”;
      entSharePointDocumentLocation.Attributes[“absoluteurl”] = strSharePointDocumentUrl;
      entSharePointDocumentLocation.Attributes[“regardingobjectid”] = new EntityReference(“account”, guidIncidentId);
      iService.Create(entSharePointDocumentLocation);
      return true;
}
 
Hope this helps.
 

Happy CRM’ing
Gopinath