Thursday, 26 May 2011

Office 365 and Sandboxed Solutions:Exceeded the daily resource usage quota.

"The site collection containing this sandboxed solution has exceeded its daily resource usage quota."

While working with Sandboxed Solutions on Office 365, you might get this error when you try to activate your solution. I faced this error on the Small business version of Office 365 but it has been know to occur on the Enterprise version too.
There is a limited resource usage quota alloted to each SharePoint Online sitecollection. When this usage quota is exceeded (when you try to activate your solution) , this error occurs.
So far, I have found how to resolve this issue on the Enterprise Version of Office 365 only. I am afraid there is no setting on the Small Business Version (The P1 plan) to manage the allocated resources.
The solution for this issue (on the Enterprise Version) is pretty straightforward:

Go to:
Admin ->
SharePoint Online ->
Manage ->
Manage Sitecollections->
Select your Sitecollection ->
Select Resource Usage Quota -> (on the top of the page)
Enter the new value in MB of your Usage Quota in the resources textbox->
Click Save.

Done. That's all there is to it :)
Enjoy Office 365!

Sunday, 15 May 2011

Add Web Part to Page using SharePoint Client Object Model:File not Found error.

When adding a web part to your page if you get the "file not found" error there is one small trick which you probably have to do.

You will most probably get this error if the page you are adding the web part to, is not in the root site of the site collection.

Here is the code to add a web part to your SharePoint page:

ClientContext clientcontext = new ClientContext("http://vardhaman/Sites/zevenseas/");
Microsoft.SharePoint.Client.File page = clientcontext.Web.GetFileByServerRelativeUrl("/Sites/zevenseas/SitePages/Home.aspx");
LimitedWebPartManager wpm = page.GetLimitedWebPartManager(PersonalizationScope.Shared);
string webpartxml = /*The webpart XML */;
WebPartDefinition wpd = wpm.ImportWebPart(webpartxml);
wpm.AddWebPart(wpd.WebPart, "Left", 1);

Notice that I have passed the entire url of the site when creating the ClientContext object. And also when I have to fetch the page to which the webpart should be added, I have passed the entire site relative url which includes the name of the site which I initially passed to the ClientContext Object.

I was stuck on this error for sometime because I tought that once I had passed the site URL ("http://vardhaman/Sites/zevenseas/") to the ClientContext object, I need to only pass the location of the page within the site ("/SitePages/Home.aspx") when fetching the page. But that did not turn out to be the case.

Have Fun Coding!