SP Insider - A SharePoint Blog

CSOM SharePoint Online error: The server does not allow messages larger than 2097152 bytes

If you get the following error with CSOM while trying  to upload documents to SharePoint Online: The server does not allow messages larger than 2097152 bytes

The reason is that CSOM limits SharePoint Online to 2MB file uploads by default if using the “ReadAllBytes” method.

Use the ContentStream property instead:

public void UploadDocumentContentStream(ClientContext ctx, string libraryName, string filePath) {

Web web = ctx.Web;
// Ensure that the target library exists. Create it if it is missing.
if (!LibraryExists(ctx, web, libraryName))
{
CreateLibrary(ctx, web, libraryName);
}

using (FileStream fs = new FileStream(filePath, FileMode.Open))
{
FileCreationInformation flciNewFile = new FileCreationInformation();

// This is the key difference for the first case – using ContentStream property
flciNewFile.ContentStream = fs;
flciNewFile.Url = System.IO.Path.GetFileName(filePath);
flciNewFile.Overwrite = true;

List docs = web.Lists.GetByTitle(libraryName);
Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(flciNewFile);

ctx.Load(uploadFile);
ctx.ExecuteQuery();
}
}

 

source:
https://msdn.microsoft.com/en-us/pnp_articles/upload-large-files-sample-app-for-sharepoint

 

 

Datasheet View error and solution: The list cannot be displayed in Datasheet view for one or more of the following reasons

Error message:

The list cannot be displayed in Datasheet view for one or more of the following reasons:

– A datasheet component compatible with Microsoft SharePoint Foundation is not installed.

– Your Web browser does not support ActiveX controls.

– A component is not properly configured for 32-bit or 64-bit support.

 

Symptom: When trying to click datasheet view in SharePoint 2010 with Windows 10, IE 11, and  Office 2016 (Excel 2016 x64).

 

Solution:

You just need to install the 32 bit Data Connectivity Components.

 https://www.microsoft.com/en-us/download/details.aspx?id=23734

 

By |November 29th, 2016|Uncategorized|0 Comments|

SharePoint TODAY column in calculated fields and auto updating it

There has been much discussion around using a [TODAY]  column in SharePoint Lists since SharePoint Lists and Libraries have been around. Other than being able to use [Today] to set a DEFAULT value, users have always asked if they could use it in a calculated field. There are workarounds well documented in various threads that detail creating a field called “Today”, then creating a calculated field ([CalculatedToday]) that references the “Today” field, and finally removing the “Today” field in order to be able to use “[Today]” in a calculated field.

The question that follows is always, “how do I get the [CalculatedToday] to update every day or on a scheduled basis?” Again, there are numerous articles documented on the internet that suggest adding and removing a [Today] field and SharePoint will update all the [CalculatedToday] fields with the current Date. Administrators have created scripts and even timer jobs to do this automatically. This method [...]

Adding bootstrap apps inside a Page Viewer Webpart

Problem:  Adding a bootstrap app inside a page viewer web part in SP2010 causes the formatting to be messed up.

Reason:  SP 2010 does not have the right compatibility mode required on the master page.

Solution: Open the site in SharePoint Designer

Copy the v.4 master page for the site to a new master page and add the following line as the first “meta” tag:

 <meta http-equiv=”X-UA-Compatible” content=”IE=10″ />

Click save as default master page on the ribbon.  Keep in mind this applies to all pages to the site.

 

 

By |December 18th, 2014|Uncategorized|0 Comments|

Cleaner List View Boxed style using jQuery

I’m sure we’ve all customized Lists in SharePoint to create different types of views. While most of the Styles to choose from aren’t always practical, the Boxed view is an interesting view because it creates a Table along with a row of all your properties and values, for each List item. A common issue with this view is that if you have empty values, it takes up space on the screen and is too “ugly” to use. This is particularly true if your list or library is associated with many Content Types because different Content Types may not populate certain fields. There’s also that hideous column/filter bar that doesn’t seem to have any value on a view like this.

By adding the jQuery below, you can make the Boxed view much more presentable. It will not display columns that have empty values or unchecked (yes/no) values.

$(“table.ms-listviewtable tr td.ms-stylebox table tr”).each(function() {
var [...]

By |May 20th, 2014|Uncategorized|13 Comments|

Accounting for Site / Subsite regional time zone settings

Often times, you will have custom web parts or code that write date values back to lists. In many cases, time zone settings are different across an organization and using DateTime.Now is generally not recommended.

Two scenarios come to mind. #1, when a site changes its time zone to be different than the hosted servers’ time zone. #2,  if a web part was deployed across a Site Collection and used in 5 different sub-sites with 5 different regional time zone settings.

I found the best way to retrieve a date is this here:

// time zone of site
SPTimeZone siteTimeZone = SPContext.Current.Web.RegionalSettings.TimeZone;

// currentTime will contain the current date and time according to the sites’ time zone settings
DateTime currentTime =  siteTimeZone.UTCToLocalTime(DateTime.Now.ToUniversalTime());

This will give you the current time in relation to the Site Regional Settings and will account for changes to the settings.

By |May 17th, 2014|Uncategorized|0 Comments|
  • ps
    Permalink Gallery

    Powershell script to change Sharepoint Information Policy for large document libraries (over 1 million docs)

Powershell script to change Sharepoint Information Policy for large document libraries (over 1 million docs)

Ran into an issue on a SP2010 farm that had over a million documents in a document library with a hundred thousand folders. Yes, lots of data, but not a bad practice in this case as it was tied to another system that relied on the folders.
In any case, I was unable to change information Policy on document library with many thousand folders due to SharePoint’s UI which creates a tree view of folders on the page to change the Information Policy. Not the best design. So as my browser crashed waiting for 100,000 folders to load, we came up with a Powershell script to accomplish this. This script will create an Information Policy to delete all documents inside the document library that are older than 180 days. It is applied to the content type, but is scoped to the document library itself. Other libraries on the site [...]

By |April 29th, 2014|Uncategorized|0 Comments|

SharePoint List ID and View ID Calculator

Simply paste the Url from the “Modify View” page in SharePoint and it will generate the List ID and View ID for you.

 

List ID:      
View ID:     

 

I got tired of doing this in notepad, so I built this as an easy way to get a SharePoint List ID or View ID from a Url.

For the list ID, go to List Settings, and copy the Url, and paste the url in the box.
For the list ID and the View ID, go to a list view, and click “Modify View,” and copy the url in the box.

Paste the url in the box and press ‘Submit’

Setting up Office 365 on a WordPress hosted domain name

Many people use WordPress.com for their public facing website.  If WordPress manages your domain (i.e. your name server is pointing to WordPress, then you will need to set up Office 365 DNS entries on WordPress.  When setting up Office 365, you have to add appropriate DNS entries for CNAME, SRV, TXT, and MX records. The typical instructions per Microsoft look like the following:

(These are for the surfpointtech.com domain, change accordingly)

To add these entries in WordPress, go to your Dashboard, Store, Domains, Edit Domain.  The problem is, if you paste these straight into WordPress, it will not work. WordPress uses a shortened version for CNAME.

For the SIP and LyncDiscover CNAMES, take out the “.domain.com” and it will work. If you don’t do this, you will get a “Cannot connect to server” error on Lync on your iPhone.

Below are the correct format DNS entries for WordPress hosted domains to work with Office 365 [...]

  • 091413_0250_Funwithcust2.png
    Permalink Gallery

    Fun with custom SharePoint Ribbon buttons using the built-in image formatmap32x32.png

Fun with custom SharePoint Ribbon buttons using the built-in image formatmap32x32.png

 

While creating a new ribbon button, you will have to pick the button image.

 

This handy image is located here: http://yousite/_layouts/en/images/formatmap32x32.png

Now you will need to reference the top left corner of the image:

Open it in MS Paint and hover the top left corner of the image to get the approximate values. Each image is 32×32 pixels, so you can just start multiplying by 32 to go across and same to go down to get the exact values.

So, for example, go 448 px down and 384 px from the left

This image for the check mark

is located at Image32by32Top=”-448″
Image32by32Left=”-384″ (down at the bottom right corner)

 

 

For the formatmap16x16.png image just divide by 2.

 

Here is a portion of the Elements.xml that references the button image location:

<CommandUIDefinition
Location=”Ribbon.ListItem.Workflow.Controls._children”>

<Button
Id=”SurfPoint.SharePoint.Ribbon.NewControlInExistingGroup.Notify”

LabelText=”Approve Records to Delete”

ToolTipTitle=”Approve Records to Delete”

ToolTipDescription=”Check all records to delete then press this button after all records have been selected on this page.”

Command=”SurfPoint.Command.NewControlInExistingGroup.Notify”

Sequence=”21″

Image16by16=”/_layouts/$Resources:core,Language;/images/formatmap16x16.png”

Image16by16Top=”-48″

By |September 14th, 2013|Sharepoint on Premise|1 Comment|