rated by 0 users
This post has 0 Replies | 1 Follower

Top 25 Contributor
Posts 2
ELin Posted: 06-07-2010 4:04 PM

For Microsoft Dyanamic CRM 4 it will create a post-create plug-in that will create a contextual doucment library within SharePoint whenever a new Account record is create. 

I have copied and possed the code to Visual Studio 2005  from website http://blogs.msdn.com/b/crm/archive/2008/03/28/contextual-sharepoint-document-libraries-and-folders-with-microsoft-dynamics-crm.aspx?PageIndex=2#comments the code as bellow:

In Visual Studio 2005 code:

using System; using System.Collections.Generic;

using System.Text;

 using Microsoft.Crm.Sdk;

using Microsoft.Crm.SdkTypeProxy;

using AccountCreatePlugin.SharePoint;

using System.Web.Services;

 namespace AccountCreatePlugin {   

 public class UpdateAccountOnCreate : IPlugin             {      

 #region IPlugin Members                       

 public void Execute(IPluginExecutionContext context)                    

{                                                              

DynamicEntity entity = (DynamicEntity)

context.InputParameters.Properties[ParameterName.Target];                    

string accountName = entity[”name”].ToString();                             

string accountId = context.OutputParameters.Properties[”id”].ToString();                               

Int32 spDocLibraryListType = 101;                         

Lists listService = new Lists();                           

listService.Credentials = new System.Net.NetworkCredential (”administrator”, “pass@word1″, “litwareinc”);                        

System.Xml.XmlNode SPresult = listService.AddList(accountName, accountName + ” Document Library”, spDocLibraryListType);            

string returnXml = SPresult.InnerXml.ToString();                          

DynamicEntity account = new DynamicEntity();                              

account.Name = EntityName.account.ToString();                            

account[”accountid”] = new Key(new Guid(accountId));                     

account[”new_sharepointdocumentlibraryurl”] = “http://localhost:7777/” + accountName + “/Forms/AllItems.aspx”;                              

ICrmService service = context.CreateCrmService(true);                                    

 service.Update(account);            

                        #endregion            

}           

}

In Microsoft Dynamic CRM 4 code bollow

var CRM_FORM_TYPE_CREATE = 1;

var CRM_FORM_TYPE_UPDATE = 2;

if (crmForm.FormType == CRM_FORM_TYPE_UPDATE)

 {

 var sUrl=crmForm.all.new_sharepointdocumentlibraryurl.DataValue;

crmForm.all.IFRAME_SharePoint.src = sUrl;

 }

But it does not work. Can you post the correct coding to me?

Thanks.

  • Filed under:
Page 1 of 1 (1 items) | RSS
Powered by Community Server (Non-Commercial Edition), by Telligent Systems