here we go, just some simple upload code that uploads documents into a document library.
It also checks if the same file exist in the destination library before upload.
SPSite site = new SPSite("http://mysharepointsite");
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true; // i always add this in to prevent security errors
Stream fStream = postedFile.InputStream;
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
string newFilename = System.IO.Path.GetFileName(postedFile.FileName);
SPFile fileExist = web.GetFile(destFolder + "/" + newFilename);
if (fileExist.Exists)
{
Response.Write("<font color='red'>Error: A file exist with the same filename. Please Rename this File.</font><br />");
}
else
{
web.GetFolder(destFolder).Files.Add(newFilename, contents);
completed.Text = "<br /><font color='green'>Successfully uploaded '" + filename + "' to: " + destFolder + " </font><br /><br /><br />";
}
MSCRM-Admin Sharepoint document library upload, Sharepoint, sharepoint upload, wss, wss upload
Well, update roll up 9 is out (how the hell did we get to 9??)! Jeez with all these update packs there needs to be a full job to implement all these updates on servers and implement the necessary changes the update pack doesn’t.
KB article: http://support.microsoft.com/default.aspx?kbid=977650
Download: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=5869f2b3-d1a0-4f71-8be3-fde6e8053a2e
MSCRM-Admin CRM 4.0 changes, crm, crm4, packs, update rollup, update rollup 9

Looks cool doesn’t it. well here goes nothing..
to achieve the above you will need the following (click read more link..)
// the following code is for the hover over lookup window
function OnCrmPageLoad()
{
/*
Reference the to Lookup, Provide the lookup (control) id.
*/
var PrvToLui = new LookupPreview("new_primarycontactid");
/*
Add Account Preview Information ,
returns an account entity wrapper object
*/
var accountEntity = PrvToLui.AddEntity("account");
/*
Add Account Preview Attributes,
Provide lable and schema name for each attribute
*/
accountEntity.AddAttribute("Business Phone","address1_line1");
accountEntity.AddAttribute("Mobile Phone","address1_city");
accountEntity.AddAttribute("Fax","address1_stateorprovince");
accountEntity.AddAttribute("E-mail","address1_postalcode");
/*
Add Related Entity (Primary Contact) Information
AddLinked requires the entity name and
lookup field schema name on the account.
*/
var contactEntity = accountEntity.AddLinked("contact","primarycontactid");
contactEntity.AddAttribute("Primary Contact","fullname");
contactEntity.AddAttribute("Contact Phone","telephone1");
/* ------------------------------------------------------------------ */
//Contact Entity Preview
var contactEntity = PrvToLui.AddEntity("contact");
contactEntity.AddAttribute("Business Phone","telephone1");
contactEntity.AddAttribute("Mobile Phone","mobilephone");
contactEntity.AddAttribute("Fax","fax");
contactEntity.AddAttribute("E-mail","emailaddress1");
var accountEntity = contactEntity.AddLinked("account","parentcustomerid");
accountEntity.AddAttribute("Parent Company", "name");
accountEntity.AddAttribute("Parent Street","address1_line1");
accountEntity.AddAttribute("Parent Suburb","address1_line2");
accountEntity.AddAttribute("Parent State","address1_stateorprovince");
accountEntity.AddAttribute("Parent Postcode","address1_postalcode");
accountEntity.AddAttribute("Parent Website","websiteurl");
/* ------------------------------------------------------------------ */
}
Read more...
MSCRM-Admin CRM 4.0, JavaScript crm, crm4, field, JavaScript, preview, preview window
As simple as it sounds, it ain’t simple.
you would of thought the following would work:
SPFile file = web.GetFile(strUrl);
file.name = "mynameFilename.txt";
file.Update();
does not compute..
There are 2 ways I’ve found of accomplishing this:
1. using the SPFile.MoveTo method:
string strUrl = "http://mysharepointsite/myolddocumentlibrary/Filename.txt";
string newFileUrl = "http://mysharepointsite/mynewdocumentlibrary/mynewFilename.txt";
SPSite site = new SPSite("http://mysharepointsite");
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true; // this will stop it from erroring out due to security errors
SPFile file = web.GetFile(strUrl);
file.MoveTo(newFileUrl);
2. using File.Item["Name"] method..
string strUrl = "http://mysharepointsite/myolddocumentlibrary/Filename.txt";
SPSite site = new SPSite("http://mysharepointsite");
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true; // this will stop it from erroring out due to security errors
SPFile file = web.GetFile(strUrl);
file.Item["Name"] = "NewFileName.txt";
However i have found method 1 more reliable. hope this helps!
MSCRM-Admin Sharepoint move, move sharepoint file, moving items, rename files, renaming files, sharepoint rename
Recent Comments