HI
Not sure if this is the right place but here goes.
I am trying to create a document library using a custom entity but get all kinds of errors. I can't seem to do anything with the custom entity.
I am trying to modify code for system entity, I found on the web, to do this. I am new to C#
Any help would be appreciated.
using System;
using System.Collections.Generic;using System.Text;
using Microsoft.Crm.Sdk;using Microsoft.Crm.SdkTypeProxy;
using SharepointFolderCreate.SharePoint ; //points to /_vti_bin/lists.asmxusing SharepointFolderCreate.CrmServiceRef; //points to myCRNServer/mscrmservices/2007/CrmServiceWsdl.aspx
// Custom Entity Name --> new_sharepointtesting
namespace MSCRMSharePoint
{
public class UpdateAccountOnCreate : IPlugin
{
#region IPlugin Memberspublic void Execute(IPluginExecutionContext context)
{
//First we'll grab the name of our account and its GUIDSharepointFolderCreate.CrmServiceRef.DynamicEntity entity = (SharepointFolderCreate.CrmServiceRef.DynamicEntity)context.InputParameters.Properties[ParameterName.Target];
string accountName = entity["name"].ToString();
string accountId = context.OutputParameters.Properties["id"].ToString();
//SharePoint Document Libraries have a type code of 101 Int32 spDocLibraryListType = 101;
//Call the SharePoint Web Service to create a document library Lists listService = new Lists();
listService.Credentials =
new System.Net.NetworkCredential("myUID", "myPW", "mydomain");
//System.Xml.XmlNode SPresult = listService.AddList(accountName, accountName + " Document Library", spDocLibraryListType);System.Xml.XmlNode SPresult = listService.AddList(sharepointtestName, sharepointtestName + " Document Library", spDocLibraryListType);
//grab the return xml string returnXml = SPresult.InnerXml.ToString();
//Now we'll update our account record with the URL of the contextual SP library
//DynamicEntity account = new DynamicEntity();
//account.Name = EntityName.account.ToString();
//account["accountid"] = new Key(new Guid(accountId));
//account["new_sharepointdocumentlibraryurl"] = "Sharepoint server" + accountName + "/Forms/AllItems.aspx";SharepointFolderCreate.CrmServiceRef.DynamicEntity new_sharepointtesting = new SharepointFolderCreate.CrmServiceRef.DynamicEntity();
new_sharepointtesting.Name = SharepointFolderCreate.CrmServiceRef.
EntityName.account.ToString();new_sharepointtesting["new_sharepointtestingid"] = new SharepointFolderCreate.CrmServiceRef.Key(new Guid(New_sharepointtestingid));new_sharepointtesting["new_sharepointdocumentlibraryurl"] = "Sharepoint server/" + sharepointtestName + "/Forms/AllItems.aspx";
//Using the iPlugIn interface we create a reference to the CrmService web serviceICrmService service = SharepointFolderCreate.CrmServiceRef.context.CreateCrmService(true);
SharepointFolderCreate.CrmServiceRef.
service.Update(new_sharepointtesting);
//service.Update(account);
}
#endregion
}
}
*This post is locked for comments
I have the same question (0)