Thursday, August 21, 2014

Using SPWeb.EnsureUser in SharePoint

I faced this scenario many times and when I Googled, there are many who have faced the same. I had added an Active Directory group to the site members group. Then I asked them to log in and make requests for a particular business scenario that triggered workflows. I had a scenario that another user could make a request on behalf of another. Simply someone is asking to reset an AD account of a person who lost his password. Given that there is a need to add a new list column called 'On Behalf Of' which is a person or group column, I simply used code to create an SPUser object through C# code using the people picker value where people picker was available in the request form to select the on behalf of user. 

I got the username from the people picker comma separated values and used the following code to get the user.

SPUser onBehalfOfUser = web.AllUsers[onBehalfOfuserLoginName];

Wednesday, August 13, 2014

Creating a SharePoint list and Adding List Items in SharePoint Apps

In my previous article I explained how to read from a SharePoint list available inside a SharePoint App site. In this article my focus would be on how to create a list inside the app and how to add list items to it. The same app I used in the previous example will be used here. Here is the code available in my Default.aspx file. It is simple just a textbox and a lable inside a HTM table and a div which includes an unordered list.

I will start having the same set of definitions in the top.

var context = SP.ClientContext.get_current();
var web = context.get_web();
var user = context.get_web().get_currentUser();
var lists = web.get_lists();

Thursday, August 7, 2014

Reading a SharePoint List using JavaScript Object Model

Using JavaScript is the buzz since the introduction of the SharePoint apps. The JavaScript client side API has improved quite a lot in SharePoint 2013 and this is the only option if you are developing a SharePoint hosted app. When comparing with the server-side object model, I did not found many conceptual differences in the API. If we are to access a list, what we need to do is refer the current site through the current context and then refer the list available in the current site. 

Here is the div tag available in my Default.aspx file which contains an unordered list inside. Forget about the other items later. Will discuss about it in next post.


<div>
<ul id="ToDoItems"></ul>
</div>


Here are some important objects created in the JavaScript API and look how similar they are with the Server-side object model.

Wednesday, August 6, 2014

Working with Napa Office 365 Development Tools

In my previous article I gave an introduction on how to start Office 365 development with SharePoint Online and how to Add the app into SharePoint online. In this article I will be focusing on working with Napa Office 365 Development Tools. You can go to the development portal at https://www.napacloudapp.com/. Make sure you have signed into Office 365 so the apps available for the particular environment will be displayed. 

Napa Projects Home
Click on the Add New Project link and a popup will appear. Select App for SharePoint and give a project name. (I give mine as DemoApp1). You will be navigated to the development environment. 

Monday, August 4, 2014

How to start Office 365 SharePoint Development

Office 365 is a hand full package. It includes many services where the key services are  SharePoint Online, Exchange Online and Lync Online. As you may have in all the systems, Office 365 also has an admin panel which is called 'Office 365 admin center'. The image below is a screen caption of the Office 365 admin center.

Office 365 admin center
You may have access to this or you may not. The main development focused on Office 365 is SharePoint. With SharePoint 2013, its mostly about apps. In this article I will describe how to start creating a SharePoint app using "Napa Office 365 Development Tools". 

Wednesday, July 30, 2014

Modifying BDC Model Entity in Business Connectivity Services

In this article I am going to customize the BDC model in a way that the entity can be used to add many properties than the 2 that comes by default. This part is a little bit tricky and confusing for a conventional C# developer. But with practice and by understanding the concepts, this can be made easier. 

1. First of all I am going to create an empty SharePoint project using Visual Studio. This example will be done using Visual Studio 2010 and SharePoint 2010, but there will be no difference for Visual Studio 2012/2013 and SharePoint 2013.

2. Then I added a new Business Data Connectivity Model to the project named 'BdcDemoModel'. The project should look like this.


3. Remove the 'Entity1' objected from the BDC Designer. Then drag and drop a new 'Entity' to the BDC Designer from Toolbox. There will be an empty entity without any identifiers or methods. 

Thursday, July 10, 2014

BCS in SharePoint 2013 @ SharePoint Sri Lanka User Group, July 2014 Meetup

  • What is a Business Connectivity Service?
  • Why use business connectivity services?
  • How to deploy a Business Connectivity Service? 

These were the key questions focused for the first session for the SharePoint Sri Lanka User Group meeting for July 2014. 
Connecting data from external data sources to SharePoint is something developers may see challenging. SharePoint 2013 has a really good feature (which was in SharePoint 2010 as well) further improved with multiple data source supports as well as features such as remote event receivers.

External Content Types provide the facility to connect the data to SharePoint and a Secure Store Service application can be used for providing the better authorizations. 

Slides of the presentation can be downloaded from below.