October 19, 2016

How to create Custom action to deploy with Sharepoint Add-ins(Apps)

There are two basic types of SharePoint Apps/Add-ins: SharePoint Hosted and Provider Hosted. Here, I will show how we can create custom action in host web document library through SharePoint Add-ins and open a model popup on click. Follow below steps:

Step 1:
Open your SharePoint App project in Visual Studio Solution. Add New Item, select Ribbon Custom action and give it name and click on Add.

Step 2:
Now in second dialog box, we have to set properties for custom action. In Dialog box. Select appropriate option based on requirement. Here, I have selected custom action scope to "List Template" and custom action scope location set to "Document Library" and click on Next.

You can select any type like Custom List, Calendar, Form Library etc.

Step 3:
Now in third dialog box, we have to specify the settings to generate a button control for ribbon. Here, I have selected "Ribbon.Documents.EditCheckout" as control location (Ribbon group where you would like to put the Control), "Demo Modal" as button control text (Name of your Control), and provide default page URL where button control navigates. Click on Finish. Now, custom action is created.

Step 4: 
Open Elements.xml file and add following attributes in <CustomAction> tag.


Your Elements.xml file looks like below

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="26a48039-5fc9-45fc-aabb-287b3ccedd3f.Demo_Modal"
                Title="Demo Modal">
        <CommandUIDefinition Location="Ribbon.Documents.EditCheckout.Controls._children">
          <Button Id="Ribbon.Documents.EditCheckout.Demo_ModalButton"
                  Image16by16="_layouts/15/images/placeholder16x16.png" />
          SPListItemId={SelectedItemId}&amp;SPListId={SelectedListId}&amp;SPListURLDir=      {ListUrlDir}&amp;SPSource={Source}"/>
    </CommandUIExtension >

Step 5:
Now open navigation page (App Page - default.aspx) of custom action and add below code:
<WebPartPages:AllowFraming ID="AllowFraming" runat="server"/>

All done! 
Now, we can deploy app in SharePoint and custom action will be created. It will open Modal Popup on click of "Demo_Modal".
Deployed app will looks like above Image. This is a great way to extend functionality of SharePoint.

If you have any questions you can reach out our SharePoint Consulting team here.

October 6, 2016

Sharepoint 2010: Excel Services workbook larger than maximum size allowed to be opened in browser.

Issue: Recently, when I was trying to open Excel workbook from one of SharePoint document library in browser, getting this error: "This workbook is larger than the maximum workbook size allowed to be opened in the browser".

By default, SharePoint as out-of-the-box allows workbook size to be opened in browser is 10 MB. If we try to open it with more than 10 MB size, then will get this error.

As part of solution, we can change the workbook size setting from central administration by following below steps:

1. Login Central Admin as a Farm Administrator.
2. Click on “Application Management” in the left navigation.
3. Click on “Manage service applications” under Service Applications.
4. Click on “Excel Services Application”.
5. Click the “Trusted File Locations” link.
6. Select the Reports library or Document library where the files are (i.e. https://www.binaryrepublik.com/work)
7. Scroll down to “Workbook Properties” and change the “Maximum Workbook Size” as per requirement. (i.e. 50 MB).
8. Save the changes.
9. Now, any workbook up to 50 MB in size from the location can be opened in browser.

If you have any questions you can reach out our SharePoint Consulting team here.

Why Multiple Inheritance is not supported in C#/VB.Net?

As we know, Object oriented programming helps us to reuse common Data Members and Methods in different class with the help of Object Oriented Programming Concept called Inheritance.

In general, there are five types of inheritance –
  1. Single Inheritance
  2. Multiple Inheritance
  3. Hierarchical Inheritance
  4. Multilevel Inheritance
  5. Hybrid Inheritance

Among these, Multiple Inheritance is not supported in .Net.

What is Multiple Inheritance?
When a class acquires features from two or more base classes, it is called Multiple Inheritance.

Above diagram represents Multiple Inheritance example which is not supported in .Net. 

Let’s see now the reasons for this diamond problem – Why multiple inheritance is not supported in C#/VB.Net?

There is a possibility that Multiple Inheritance will cause ambiguity problems. It happens when two or more parent classes will have members with same identifier. Let’s understand this by an example.

In above example –

  1. Class A and Class B have same method called “Calculate(int val1, int val2)”.
  2. Class C inherits Class A & Class B. [.Net does not support this. It is shown here for example only].
  3. In Class C, we are trying to call a method from base class - “base.Calculate(10, 10)”.
  4. Now here, ambiguous situation arises. Compiler cannot identify which method to call, from Class A OR Class B.
  5. To avoid this situation, Multiple Inheritance is not supported in .Net.

So basically, Multiple Inheritance is not supported in .Net to avoid ambiguity. However, Interface is an alternate that can be used in .Net to avail Multiple Inheritance.

If you have any questions you can reach out our SharePoint Consulting team here.

October 5, 2016

Error occurred while restoring site to new tenant - 0x80070003

While restoring site collection from one farm to another using power shell command: Restore-SPSite, I am getting below error.

Error: :-  <nativehr>0x80070003</nativehr><nativestack></nativestack>.Exception.GetType().FullName, <nativehr>0x80070003</nativehr><nativestack></nativestack>.Exception.Message

Below are few possible reasons you might get this error:

1) SharePoint Version differs: Version may be lower in destination farm than source farm environment. It can be verified by Go to Central Administration --> System Settings --> Manage Servers in the farm and check version.


Resolution: Version in destination farm i.e. where we restore site collection must be same as source. Upgrade the version by installing necessary Service packs or Cumulative Updates.

2) SQL Server Version differs: SQL Instance version may differ in destination farm where we are restoring site collection, from the source farm where we have taken site collection backup.

Resolution: Install correct version of SQL Server with service pack in destination farm.


3) Memory Insufficient: In my case, both SharePoint farm and SQL Server versions were same. So, I checked SQL Server Logs through ULS log viewer and came to know that there was insufficient memory to execute queries in content database.

Resolution: Connect SQL Server by SQL Server Management Studio --> Right click and go to properties and increase Maximum Server Memory according to need.



 If you have any questions you can reach out our SharePoint Consulting team here.