Monday, 11 January 2016

How to add references for Microsoft.BusinessData.dll and Microsoft.Office.SecureStoreService.dll for a SharePoint 2013 Visual Studio Project

Recently I had issues in adding references for Microsoft.BusinessData and Microsoft.Office.SecureStoreService for a SharePoint 2013 Visual Studio Project. Actually it took me time to find out their locations as one resides in ISAPI folder and other one is in GAC_MSIL. You will not find them by simply going for C:\Windows\Assembly on its default view.

To add them simply using Browse on “Add Reference” dialog on your Visual Studio Project.

Location of Microsoft.BusinessData : C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI


Location of Microsoft.Office.SecureStoreService : C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Office.SecureStoreService\v4.0_15.0.0.0__71e9bce111e9429c



Monday, 21 December 2015

How to allow READ ONLY/unauthenticated SharePoint users to add an Item in a SharePoint List using an Application Page without giving them “View Application Pages” List Permissions.

Case: I have a SharePoint Site that has a few lists, site pages, application pages etc. One of my application Page was custom coded to allow end users to add an item in a SharePoint List after successful submit a success message was showing using a popup dialog page.

My Permissions are supposed to be set so that end-users should have Read Only permissions and they should not be able to see (i.e. Site Contents to prevent them showing all SharePoint lists or document libraries) any system Pages to system and application pages except the Contact Us and popup dialog so that end users can effectively add a new item in one of the list.

Please note the solution I am describing is one of the possible. There are and can be alternatives to mine. I am merely providing the approach that I have used. My main aim is to do minimum work and get the site working with most of customization. I planned to have a permission set that can allow me to access to Site Pages, and one or more application pages that I deployed. I wanted to make sure that System and other application pages are not accessible. I also wanted end users to have site access.
Hence I have created and customized one permission set and apply it to a group on parent level hence not indulging with breaking Inheritance issues. Finally I used UnsecuredLayoutsPageBase to drive my application pages that I wanted end users to have access.

I have achieved this by following steps:

1.      I created a Permission Level as following
a.      Under List Permissions Only two permissions– Select “Add Items”, it has dependency on “View Items” so let both of them be selected.
b.      Under Site Permissions Only five permissions-> Select “View Pages”, “Browse User Information”, “Use Remote Interfaces”, “Use Client Integration Features” and “Open”.

A note, if I select "View Application Pages" then it works but problem is that you will see other application and system pages as well.

2.      I created a Group and assigned the newly created permission set to it.



4.      I opened my Application and Popup pages and change the code so that they are inherited from UnsecuredLayoutsPageBase rather than SecuredLayoutsPageBase. I also made sure that code that is actually adding an item in the list, is running with Elevated Privilege.


5.      Deploy and test.

Wednesday, 9 December 2015

Error while retrieving data from SharePoint 2013 External Content Types: An error occurred while retrieving data from "Name of Secure Store Target Application". Administrators, see the server log for more information.

Error Message: An error occurred while retrieving data from <Name of Secure Store Target Application>. Administrators, see the server log for more information.

Problem: When try to read data from an external data source using SharePoint’s External Content Type functionality. Your users are getting above error. You might have tried to play with Business Data Connectivity Permissions including granting all permissions (Edit, Execute, Selectable In Clients, Permissions) in either/both “Set Object Permissions” or “Set Metadata Store Permissions” but with no success.


Edit
Execute
Selectable In Clients
Set Permissions
http://ipcds0002:45274/_layouts/15/images/blank.gif?rev=23
Propagate permissions to all methods of this external content type. Doing so will overwrite existing permissions.


If above is true then its worth to check your permissions for Secure Store Target Application. You have to update and add your users/group who need to access the data from Secure Store Application into “Members”.

There are essentially two steps to grant permissions on your External Content Types after you successfully created and tested it, so that intended users should be able to use external data.
1.  Make sure you provide “Execute” permission to your users in Central Administration à Manage Service Applications à Business Data Connectivity Service à Double click on it and select your External Content Type à then Click on “Set Object Permissions”à Add your user/group here and assign only “Execute” permission. You can assign more permissions if needed here.
2.  Make sure you provided a mapping of your end users with the credentials you are using to access your external data. Normally you associate one account that will be used by secure store to connect with external data source. Once the connection is successful you have to provide a group/people who can use Secure Store Target Application. In order to do so, you will have to go to Central Administration à Manage Service Applications à Secure Store Service à Double Click it à Select your Secure Store Target Application à Double Click on it à It will open edit screens à Navigate to next screen and then next again à On final page you would see two groups à One for Secure Store Target Application Administrators (The people in this group would be able to modify the Secure Store Target Application settings, if they have permission for Central Administration site.), the other for Secure Store Target Application Members, this is the group we should add our target users/group on SharePoint that we want to provide access to external data.


Please refer attached screens.
The first screen shows how to set permission on "Business Data Connectivity Service".

The Second screen shows how to set permission on "Secure Store Service"



Tuesday, 24 November 2015

When you create a site in SharePoint using its "Save Site As Template" functionality, NO data in Web designer Galleries --> Composed Looks library.

Problem: 


When you create a site from Save Site As Template functionality either using Visual Studio to modify the wsp or directly creating a site from the Template. You don’t see any data in Web designer Galleries à Composed Looks library. Normally this library should have data similar to following:


Whereas you see similar to following when a site was created using "Save Site as template" WSP.




Reason: When you create a Site using the wsp that was created by "Save Site as Template" functionality, it changes a XsltListViewWebPart to ListViewWebPart in _layout\design\AllItems.aspx page.


Solution: To replace ListViewWebPart by XsltListViewWebPart.

Following picture is showing correct content of AllItems.aspx page (taken from a working site that displays correctly data in Web designer Galleriesà Composed Looks).



Whereas following pictures shows incorrect ListViewWebPart is placed in AllItems.aspx (taken from a non working site that displays no data in Web designer Galleriesà Composed Looks.)


To fix the issue please follow following steps:

Step 1: Open the WebSite that shows correct data in a SharePoint Designer instance. Navigate to All Filesà _catalogàdesignàAllItems.aspx page and open the file.

Step 2: Copy the section that has WebPartPages:XsltListViewWebPart  to a Notepad file lets name it Target.txt. We will use this to create our own WebPartPages:XsltListViewWebPart tag and will finally replace that to the AllItems.aspx page of the site that is not working.



Step 3: Now open our site that has problem, using SharePoint Designer. Navigate to All Filesà _catalogàdesignàAllItems.aspx Page and create a copy of this page so that if something goes wrong then you can always restore it.

Step 4. Checkout the AllItems.aspx page. Locate the WebPartPages:ListViewWebPart tag. Copy the whole tag to notepad file, lets name it Source.txt.

Step 5. We will use data (only some Guids) from Source.txt and will replace those Guids at correct places in Target.txt. Finally we will have our tag ready to be replaced in problematic AllItems.aspx file. Please refer following picture for data that has to be replaced in Target.txt from Source.txt.

Step 6. You will have to replace 1, 4, and 6 with View Name value from Source.txt.
Step 7: You will have to replace 2 with ListName from Source.txt.
Step 8: You will have to replace 3 with ListId from Source.txt.
Step 9: Finally your content in Target.txt are changed something similar to the following:
Step 10: Now replace the content of Target.txt into WebPartPages:ListViewWebPart tag in AllItems.aspx of the site that is not displaying Composed Looks data.
Step 11: Save and check in the file and try browsing content of Composed Looks and you should see your data.


Thursday, 19 November 2015

Error occurred in deployment step 'Add Solution': The XSN cannot be used on the server.

This morning I had an issue while deploying an InfoPath 2013 form to a SharePoint Server using Visual Studio 2015 feature framework. The weird error message was as follows:

"Error occurred in deployment step 'Add Solution': The XSN cannot be used on the server."

After playing with InfoPath Designer's publishing options it turned out to be a very simple problem.

You have to publish the form to network location, with domain level security and Access Path should be blank. I have posted a few picture to explain where would you have an option to leave "Access Path" as Blank.









Thursday, 8 October 2015

How to force an Update to SharePoint Solution Packages (WSP) in Visual Studio 2015 without using "Deploy" option

Recently I had hard time to figure out that why my features are not getting upgraded using Update-SPSolution Power-shell script.

It turned out a very silly behavior of Visual Studio 2015. Whenever you build/rebuild your solution it doesn't update WSP file. However if you want to redeploy your solution then Visual Studio's "Deploy" option force an update on WSP file. Since I am performing an upgrade on my features "Re - Deploy" was not an option.

After finding this behavior initially I thought of using Ms-build to create a wsp file and get the work done and this is what people normally do. But somewhere in my mind I was puzzled what if I have to use Visual Studio for this? Turn out to be very simple option. You can use "Publish" your solution to file system. It forces a new build and proper update of artifacts within WSP.


Thursday, 6 August 2015

How to change column names and column orders in one or more lists but not to all lists that are based upon a Site Content Type.


If you have a Site content type and if there are more than one lists that are using it. Sometimes you might have requirement to change column names and column order only in one or more lists but not all. If you make these changes to Site Content Type then it will affect all. You can try doing it at List Content Type level rather than at Site Content Type level. It is fully supported. You can make some interesting local changes that are applicable to one or more list but not to all. For example you can delete some columns in the list content type for one or more lists or you can change column order etc.