Wednesday, 6 July 2016

How to run Leaderboard meteor example on Windows 10

As I mentioned in my last post that I have started exploring Meteor recently on my very old laptop that I have upgraded to Windows 10. I am going to blog simple to complex issues that I encounters during my exploration phase.

The second hurdle was to run leaderboard example :).

I tried following:

meteor create --example

As I am not using Mac, I received an error message saying that I should use clone git repository using following command. When I try to execute the following command then I received one more error message complaining about that "git" is not recognized as internal or external command.

git clone https://github.com/meteor/leaderboard


So the next thing I did that I downloaded Git for Windows v2.9.0 from

https://git-for-windows.github.io/index.html

Once downloaded and installed then I closed windows command prompt.

After running windows command prompt again and following above commands I was able to run leaderboard successfully :).

Installing Meteor on Windows 10 in 10 minutes :)

Recently I started exploring Meteor. The initial glitch I had on installing it to my Windows 10 machine. Thought of listing following five steps to get it done.


Step 1. Browse to https://www.meteor.com/install

Step 2: Click on "Download Installer" on Windows section.



Step 3: Install and create a developer account (optional).

Step 4: Restart the machine

Step 5: Open a new Command Prompt and type "Meteor"



You are all set up to go ahead. Happy coding :)



Tuesday, 19 April 2016

Creating HTML controls in SharePoint List Views and calling JavaScript code from their events!

If you ever need to create some HTML controls in a SharePoint List Views and have to associate some action on some events such as open a dialog form on a click of a HTML Button. 



You can use calculated columns. All you have to do is to define your HTML code in a calculated column and if you are adding some funky logic then add your java script file on the page.

Calculated Column formula: ="<DIV><input type='button' id='clickDetails' value='+'  onclick='javascript:popUp("&IdValue&");'/></DIV>"



Don't forget to change "The data type returned from this formula is:" to either Number, currency etc. If you keep it as "Single line of text" then HTML will render as text not as HTML control.


Where popUp function is defined in the included js file as following. You can include this java script on the page using many methods. For an example you can use a script editor web part to do so.

<script type="text/javascript">
function popUp(Id) {            
    var siteCollUrl = _spPageContextInfo.siteAbsoluteUrl;
    var pageUrl = siteCollUrl + '/SitePages/mypage.aspx?Id=' + Id;
    var options = {
        url: pageUrl,
        args: null,
        showMaximized: false,
        width: 1020,
        height: 750,
        title: 'Collect some data',
        dialogReturnValueCallback: function (dialogResult) {
            SP.UI.ModalDialog.RefreshPage(dialogResult);
        }
    };
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}
</script>

Thursday, 25 February 2016

How to create a new Site Collection from an existing one.

Recently I had a requirement to create a exact same copy of one site collection to another new web application.

I used following power shell comdlets to do the job very quickly.

http://xxxx:6203--> This is my root level site collection that I want to copy and spin a new site collection on a new web application.

http://xxxx:43583 --> My New Web application that is just created and no site collection is assigned to it.

Step 1: Create a back up from the source site collection

Backup-SPSite -Identity "http://xxxx:6203" -Path "C:\YS\abc.bak"

Step 2: Create a Web Application

Step 3: Do not create a site collection for new Web Application as we will use our backup to do that.

Step 4: Restore the backup on the new Web Application where http://xxxx:43583 is Web Application url.

Restore-SPSite "http://xxxx:43583" -Path "C:\YS\abc.bak"

Step 5: Verify and test.

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"