Category Archives: Visual Studio

SharePoint - Creating a Custom ToolPart for a Custom Web Part


You may also be interested in: Find and Move Files from anywhere to SharePoint with Skybrary


 

Editor’s note: Contributor Adeel Ehsan is a Developer / IT Trainer in Dubai, UAE

Using the SharePoint object model it is easily possible to create a custom properties panel for a custom Web Part, known as ToolPart.

While creating custom Web Parts, we might need to create a custom properties panel that appears when we edit a Web Part using the browser. In this article we will see how to do that using Visual Studio 2010.

Default ToolPart

The following figure shows the default toolpart that appears when we edit a Web Part:

2013-01-29-CustomToolpart-01.png

Creating a Standard Web Part

Using Visual Studio 2010, create an Empty SharePoint Project and add a standard Web Part in it. Modify the code as below:



IMPORTANT:
The standard Web Part class must inherit from Microsoft.SharePoint.WebPartPages.WebPart class. This will give us an override-able method GetToolParts that is fired to get the toolparts for a Web Part. This method is returning all toolparts for the Web Part in the form of an array of type Microsoft.SharePoint.WebPartPages.ToolPart. To add a custom toolpart we need to create a custom class in the same project inheriting from Microsoft.SharePoint.WebPartPages.ToolPart class.

Add the following class after the Web Part class in the same project:



In the Visual Studio solution explorer, right click and click on Deploy.

Testing the web part:

  1. Open the SharePoint site in the browser for which the project was built and deployed.
  2. On the home page, or any page, Edit and insert the Web Part. You will find the Web Part in Custom category by default.
  3. We will see the following after adding the web part on the page:
  4. 2013-01-29-CustomToolpart-02.png

  5. Click on the small dropdown icon and Edit the Web Part, we will see our custom toolpart like:
  6. 2013-01-29-CustomToolpart-03.png

  7. Try to change the two properties and see the effect on the output of the Web Part.

One Final Tweak:

If we would like to just display our own custom toolpart, then modify the GetToolPart() method in the standard Web Part class like the following:



The above will make sure that you see only your custom toolpart like this:

2013-01-29-CustomToolpart-04.png

Resources:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpart.aspx
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.toolpart.aspx

SharePoint 2013: Custom Error Pages


You may also be interested in: Critical Path Training


 

Editor’s note: Contributor Gokan Ozcifci is a SharePoint Consultant at Vision IT Group. Follow him @gokanozcifci

A great change in the new version of SharePoint Server is that there is a support of Custom HTTP 404 Error Pages. In this post we will take a look how to create a new 404 page.

All Publishing sites contain a default a 404 Error page “PageNotFoundError.aspx” page which is added to the App "Pages Library" therefore connect to a Publishing site. If you don’t have any publishing sites, check the image, to see how to create one.

2013-01-20-CustomError-01.png

After you create your site, you can go to your site’s contents and check under your App "Page library" for the current and out-of-the-box PageNotFoundError.aspx

2013-01-20-CustomError-02.png

To allow users to create a new custom Error page, Publishing Sites now contain a new Content Type “Error Page“. This Content type Inherits from “Page” Content type and has a typical layout of a Page Not found. To find this Content Type, Navigate to Site Settings -> Content Types -> Error Page.

2013-01-20-CustomError-03.png

You can modify this page to add some text or images. But we want to create a new custom Error Page. For this go back to your App "Page Library" and create a new document "Error Page"

2013-01-20-CustomError-04.png

Provide some information and be sure that you select an (Error Page) Error.

Title: Custom Error Page
Description: Custom Error Page gknzcfc.net
URL Name: Custom-Error-Page

2013-01-20-CustomError-05.png

You will now see your new page appearing under your App.

2013-01-20-CustomError-06.png

Check out, and make modifications to your page. I’m a huge lover of Doctor House, so I added a picture of him to make clear that the page was not found :^)

2013-01-20-CustomError-07.png

I received a question from Isha [MVP SharePoint] asking about "how we could set a custom error page as default

2013-01-20-CustomError-08.png

The answer is quite simple:

2013-01-20-CustomError-09.pngRename "your" custom error page to PageNotFoundError.aspx and delete the out-of-the-box

2013-01-20-CustomError-09.pngUse the FileNotFoundUrl via Visual Studio. Get the SPSite server relative URL or absolute URL to the file not found page. This value is used as a redirect URL for an HTTP request where the resource cannot be found.

But, what if you do not want to create a new one, but only want to modify?

We’ve all seen it; the SharePoint 20xx error message is something terribly not "user-friendly".

Now, I like the Correlation ID and being able to track the error down. However, in real world scenarios it’s unlikely that our users will leave this screen up and copy/paste to our support group. Wouldn’t it be nice to have a warmer error message with our company logo and a link that will ask the user to send the error details?

2013-01-20-CustomError-09.pngConnect your Application Server and navigate to 15>TEMPLATE>LAYOUTS

2013-01-20-CustomError-10.png

2013-01-20-CustomError-09.pngLocate and copy the error.aspx file. Never never never ever touch the system files. Make copies and use those and if something goes wrong you can always come back.

2013-01-20-CustomError-11.png

2013-01-20-CustomError-09.pngOpen the error.aspx with notepad and paste the following items to get a LOGO and a HYPERLINK:

Logo


<asp:Panel id="ErrorPageTitlePanel" runat="server" tabindex="0">
<img src="vcg.jpg"/><br/><br/>Vision Consulting Group:</span>
< /asp:Panel>

Ticket Link


<asp:Panel id="PlaceHolderPageTitleInTitleArea" runat="server"><p>
<a href="mailto:info@gknzcfc.net?subject=New SharePoint Incident&body=<Please provide a short description and paste error >">Log SharePoint Support Ticket</a></p></asp:Panel> 

2013-01-20-CustomError-09.pngYou can choose where you want to copy those elements (think logic). When finished, you can save and try to get a Correlation ID. If everything went right, you should receive an error screen like this:

2013-01-20-CustomError-12.png

2013-01-20-CustomError-09.pngAnd when somebody clicks on "Log SharePoint Support Ticket" Outlook will open a new message and the user has only to enter some information and click "send"…

2013-01-20-CustomError-13.png

Happy Configuring,
G.

SharePoint: Showing Notification and Status Message Using SP.js


You may also be interested in: SharePoint Smart Notifications by KWizCom


 

Editor’s note: Contributor Adeel Ehsan is a Developer / IT Trainer in Dubai, UAE

It is very important to notify end users about the actions that are going on. Doing it in SharePoint standard style is the way to go. In this article we will see how to display notification and status messages using sp.js support with Visual Studio 2010.

What are those?

The following figure shows the notification and status messages in a SharePoint site during different operations:

How to do it

We will create a visual web part that will perform some server side actions. After that it will show notification and status messages to inform the user, just like above. This will work in the standard web part as well.

Creating Visual Web Parts in Visual Studio 2010:

  1. Go to File-New-Project. Under SharePoint 2010 project templates, select Visual Web Part template. Choose name, location and click ok.
  2. Next, choose an existing SharePoint site for debugging and choose Deploy as Farm Solution.
  3. This will add various project items that you could see in the solution explorer. One of them is VisualWebPart1 that is the actual visual web part.
  4. Expand it and you will see the web user control files, VisualWebPart1UserControl.ascx and VisualWebPart1UserControl.ascx.cs. As we know, VisualWebPart is a web user control (.ascx) being loaded using a standard web part.
  5. Go to the source view of the VisualWebPart1UserControl.ascx and add the following JavaScript:

  6. <script language="javascript" type="text/javascript">
        var statusID;
        function showNotif() {
            SP.UI.Notify.addNotification('Done with the processing...', false);
            statusID = SP.UI.Status.addStatus("Title:", "Your request has been processed.");
            SP.UI.Status.setStatusPriColor(statusID, 'green');
            setTimeout(function () { SP.UI.Status.removeStatus(statusID); },4000);
        }
    </script>
    

    IMPORTANT:
    The above JavaScript code is using SP.UI namespace to show notification and status. SP.UI.Notify class has a method addNotification() that will display a notification and it takes 2 parameters: first is the text (html) that you want to display and second is a Boolean parameter that will specify whether the notification stays as sticky notification or not. In this case false means, it should disappear after a few seconds.

    SP.UI.Status class has a method addStatus() that will display a status message and it takes 2 parameters; the first one is title, which is always rendered in bold and second is the actual text (html). Since status message will not disappear automatically, we need to save its ID in a variable and later remove it. SP.UI.Status.setStatusPriColor() method is used to set the background color of the message.

    After a delay of 4 seconds, the status message is removed using SP.UI.Status.removeStatus() method that takes the id of the status.

  7. Next, add the following markup below the script which will add a button with 2 labels:

  8. <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Click Me" />
    <p>
        <asp:Label ID="Label1" runat="server" Text="Waiting for click...and will show notification "></asp:Label>
        <asp:Label ID="Label2" runat="server" Text=""></asp:Label>
    </p>
    

  9. Label1 will be used to display some server side processed messages, and Label2 will be used to run JavaScript function showNotif() to display notification and status messages.
  10. Go to the code behind file VisualWebPart1UserControl.ascx.cs and add the following code in the Button1_Click() event handler so that it looks like: (Double Click on the Button1 in design view to create following event handler)

  11. protected void Button1_Click(object sender, EventArgs e)
            {
                this.Label1.Text = "Finished processing on " + DateTime.Now.ToString()+   ". [Set from code behind]";
                //set the script over the label using SP.SOD.ExecuteOrDelayUntilScriptLoaded
                //this method will wait for sp.js to be loaded fully before calling 
                //showNotif javascript method
                this.Label2.Text = "<script>ExecuteOrDelayUntilScriptLoaded(showNotif,'sp.js');</script>";            
            }
    

  12. In the above code, on the first label, we are simply setting a message concatenated with current date and time. In a real application, this can be any valid allowed SharePoint processing. On the second label we are setting a script call as text that will cause our JavaScript function to run.
  13. IMPORTANT: We have to use ExecuteOrDelayUntilScriptLoaded() to invoke the JavaScript function so that sp.js is fully loaded before the function tries to run. If we do not use it, we will run into a JavaScript error.
  14. That’s it for the development. In the Visual Studio solution explorer right click and say Deploy.

Testing the web part:

  1. Open the SharePoint site in the browser for which the project was built and deployed.
  2. On the home page, or any page, Edit and insert the visual web part. You will find the web part in Custom category by default.
  3. We will see the following after adding the web part on the page:
  4. Click on the Button and we will see the following:
  5. In the above image we can see the notification and status message.
  6. After 4 seconds the status message will be removed and after a few more seconds, the notification will be removed as well.

Note: You can choose to show the status message and/or notification accordingly.

References:
http://msdn.microsoft.com/en-us/library/ee552096(v=office.14).aspx [SP.UI namespace]

Sequential Workflow in SharePoint 2010 Using Visual Studio 2010


You may also be interested in: SharePoint Services with mindfiresolutions


 

Editor’s note: Contributor Venkatesh Kumar is a Senior Developer for Cognizant. Follow him @venkat_mru

Introduction

In this article we will see how to create a sequential workflow in SharePoint 2010 using VS 2010.

Objective

Let’s make the scenario simple. We want to create a simple workflow and if the workflow status is not completed, we need to prevent the user from deleting the document.

Steps

First we need to create a "Status" column with a choice field type with various status options in our document library.

Once the "Status" column was created, the document library will be as shown below:

2012-12-19-SequentialWorkflow-02.jpg

Open the VS2010 -> Select SharePoint 2010 -> Select the Sequential workflow project type and complete the wizard as shown below.

2012-12-19-SequentialWorkflow-04.jpg

By default we have the following simple start page:

2012-12-19-SequentialWorkflow-05.jpg

Just click the OnWorkFlowActivated step and create an event called OnWorkFlowActivated_Invoked:

2012-12-19-SequentialWorkflow-06.jpg

Double-click the onWorkflowActivated step. It will redirect to the code behind file.

2012-12-19-SequentialWorkflow-07.jpg

Drag a while loop step from the Tool Box, below the onWorkflowActivated step:

2012-12-19-SequentialWorkflow-08.jpg

2012-12-19-SequentialWorkflow-09.jpg

Select the while loop step and in the property window configure the "Condition" as "Code Condition" and create an event called "IsWorkFlowPending".

2012-12-19-SequentialWorkflow-11.jpg

2012-12-19-SequentialWorkflow-12.jpg

2012-12-19-SequentialWorkflow-15.jpg

Place the following in the workflow:

2012-12-19-SequentialWorkflow-16.jpg

Invoke the "IsWorkFlowPending" method in both the "onWorkflowActivated_Invoked" and the "onWorkflowItemChanged1_Invoked" methods.

2012-12-19-SequentialWorkflow-17.jpg

Let’s deploy the solution and we will check whether or not the workflow is deployed in our document library.

2012-12-19-SequentialWorkflow-18.jpg

Upload a document and start the workflow:

We will see the workflow status as "InProgress" in the document library.

2012-12-19-SequentialWorkflow-20.jpg

Edit the task and change the status to Approved. Our workflow status will change to "Completed".

2012-12-19-SequentialWorkflow-21.jpg

We can prevent the user from "Deleting" the document, if the "Status" is not completed. Just add an Event Receiver in the same workflow project.

2012-12-19-SequentialWorkflow-23.jpg

In the code behind file, we will prevent the user from deleting a document if the status is "Pending".

2012-12-19-SequentialWorkflow-24.jpg

Let’s check the code in the UI using a document which is in the InProgress Status and try to delete the document.

2012-12-19-SequentialWorkflow-25.jpg

If we click ok the document is still in our repository.

2012-12-19-SequentialWorkflow-26.jpg

Let’s make some changes in the code to display a user friendly message:

2012-12-19-SequentialWorkflow-27.jpg

Now when we try to delete the document we will see the following message.

2012-12-19-SequentialWorkflow-28.jpg

Summary

We created a simple workflow in VS 2010 which prevents the users from deleting a document, if it’s not approved.

References

http://msdn.microsoft.com/en-us/library/hh237664(v=office.14).aspx
http://msdn.microsoft.com/en-us/office2010developertrainingcourse_vs2010sharepointworkflow.aspx

SharePoint Emulators now live!!!

 

It’s great to see that the Visual Studio team has launched the SharePoint Emulators add-on for Visual Studio 2012 that works with SharePoint 2010 server-side .NET object model. I was lucky enough to get an early glimpse of this stuff when I was in Redmond for the Build conference and am really impressed with what they’ve managed to do.

Joshua Weber does a great job of explaining the benefits of this for Unit Testing SharePoint server-side .NET code in SharePoint 2010. To date it’s involved a lot of PEX/Moles or TypeMock Isolator type approaches. This approach in my opinion is a lot cleaner and a lot more extensible for your own projects.

The good news is that it’s available right now via a NuGet package so download it and give it a whirl. Yes it’s only available in Visual Studio Ultimate, which I think will hurt some development teams who don’t have this.

The framework leverages the Fakes (no not Thakes2012-11-27-Emulator-01.png) aspects of the Visual Studio 2012 suite and .NET Framework. Essentially they’ve coded an implementation of some of the major Microsoft.SharePoint.* dll’s and whatever is missing you can, in fact, actually extend yourself. The team is encouraging the community to help build out the missing shims to help with adoption of this tool.

There was a Build session on this which is available to download also here http://channel9.msdn.com/Events/Build/2012/3-015

Love to hear feedback from community on this one. I for one will be evaluating this in our internal testing here at AvePoint against our existing unit testing approaches.

Apply Custom Values to Visual Studio Workflow Statuses


You may also be interested in: SharePoint App Development by mindfiresolutions


 

Editor’s note: Contributor Nicholas Holloway is an Application Developer. Follow him @nholloway4

Today I will show you how to apply Custom Values to Workflow Statuses. We all know that improving business processes is an essential part to capitalizing on the ROI for SharePoint. By this, SharePoint Workflows are used to automate and streamline these processes. Workflow has some built in values like, “In Progress”, “Failed on Start”, Error Occurred”, etc. All of these are OOTB statuses that are provided, but what if we wanted custom values for the workflow. A custom value that would specifically show what stage in the process it is currently on.

We are able to set custom values for workflows, but this can only be achieved in Visual Studio. Subsequently, OOTB or SharePoint Designer workflows cannot be changed.

Creating these custom values can be done in Visual Studio Sequential or State Machine Workflows.

First we must open the Elements.xml file and place the code below:


<ExtendedStatusColumnValues>
        <StatusColumnValue>Pending</StatusColumnValue>
        <StatusColumnValue>Stage 2</StatusColumnValue>
        <StatusColumnValue>Stage 3</StatusColumnValue>
        <StatusColumnValue>Stage 4</StatusColumnValue>
        <StatusColumnValue>Stage 5</StatusColumnValue>
        <StatusColumnValue>Completed</StatusColumnValue>
        </ExtendedStatusColumnValues>

The code should be entered just above the ending “Metadata” xml node like so

After this is done, proceed by going to the Workflow Design view and add a “Set State” activity. Be careful as to add the “Set State” Activity in the “SharePoint Workflow” toolbar which sets the status of the state.

The “Set State” activity in the Windows Workflow v3.0 is for setting the next state in the workflow.

Once you drag the "SetState" activity on the Designer page, right click on it and open its properties. Bind its "State" properties to a variable and select "field" while binding it. Select the correlation token as "WorkflowToken" as this activity does not belong to any task. Double click on the activity and it will promt you to enter some code:

Let us assume that your "SetState" activity name is "InitialState". When you double click on the "SetState" activity, insert the line below in the code window:


InitialState.State = (Int32)SPWorkflowStatus.MAX;

The integer value for MAX is 15. The values from 0 to 14 are reserved for internal and built-in values such as InProgress, Completed, Error Occurred etc. that I stated earlier. In the elements.xml, the value of the first custom value will be 15 (See above as we specified the first custom value as Pending). It will then keep on increasing by 1. For instance, if we want to assign the "Stage 2" value to the workflow then we will write the below line of code:


InitialState.State = (Int32)SPWorkflowStatus.MAX + 1;

The line above will assign the "Stage 2" custom value to the State variable and whenever the workflow reaches this state it will show the status "Stage 2". Similarly, we can write any number of custom values to our workflow. We have used only two custom values in the above elements.xml. If we want to use a third one then we will right it just below the "Stage 2" custom value like:


<ExtendedStatusColumnValues>
        <StatusColumnValue>Pending</StatusColumnValue>
        <StatusColumnValue>Stage 2</StatusColumnValue>
        <StatusColumnValue>Stage 3</StatusColumnValue>
        <StatusColumnValue>Stage 4</StatusColumnValue>
        <StatusColumnValue>Stage 5</StatusColumnValue>
        <StatusColumnValue>Completed</StatusColumnValue>
        </ExtendedStatusColumnValues>

The value of "Stage 3" status will be assigned as follows:


InitialState.State = (Int32)SPWorkflowStatus.MAX + 2;

This pattern will continue until you have finished all statuses which is dependent upon the number of states comprised in your workflow.

If you change your workflow.xml file by changing the workflow custom values then deploy it again and run IISRESET, you’ll see the changes in SharePoint List as to when the workflow will run.

After completing the tasks at hand we can set our own custom value fields to Visual Studio Workflows.

Add “follow” to SharePoint 2010


You may also be interested in: SharePoint Solutions In-A-Box from Alcero


 

Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

For those of you who have checked out the Office 365 or SharePoint 2013 preview, you would have noticed that Microsoft has added a follow button, on sites and documents, the functionality when clicked basically bookmarks the site similar to a favourite in your web browser.

I have been working on a SharePoint 2010 project for our company, in the new web application there will be 100s of site collections and inside each 100s of sites. The sites are organised logically in a hierarchy, the challenge was that some users will always work in level 4 of the hierarchy and some will work at level 1 or somewhere in-between. As this requirement is not really prescriptive and we cannot know which user wants to navigate where, I needed to develop follow functionality similar to what Microsoft is shipping in SharePoint 2013.

This article looks at the setup and the code that has made this possible and a very popular feature with the end users thus far.

The first step is to decide upon where to store the information, for this I decided to use the user’s profile, so if you’re running SP Foundation, stop here and think about where/how you may store the information instead.

To do this I simply added a new user property called “bimsFollow”. This property was simply a string (multi value) type.

2012-09-07-AddingFollow-01.png

I also made the property hidden from the end user.

2012-09-07-AddingFollow-02.png

The next step was to build a control to be able to follow or un-follow a particular site. For this functionality I decided upon using a user control, this makes it very simply to embed the functionality in an area of my custom master page. So the first step was to open a Visual Studio project and add a new user control, for this I called it “follow”.

The only thing I needed my user control to show was a hyperlink as to whether the user was following the current site or not, so at the bottom of the .ascx file, I added the following code:



The URL and Text will be dynamic based on whether the user is following the site or not, so here I have left it blank and run the control at the server so I have access to it in the code behind.

The next step was to open the code behind file (.ascx.cs). Inside the page_load function I started by adding a couple of Boolean values:



Before constructing the bulk of the functionality I wanted to test that everything was working, so I then added the code to set the hyperlink with the correct URL and text.



I then registered the user control to the master page to make sure what I had setup was working so far, even though the if statement is always going to execute the else block at this stage. Sure enough it appeared to be working, with a bit of CSS styling I ended up with a user control that matched the style of my custom master page:

2012-09-07-AddingFollow-03.png

As you can see from the code above I decided to use query strings to toggle whether the user was following the site or not, so the first thing we had to do before the if statement is called is to get the value for the query string.



If the value exists, then we set the followMe bool to be either true or false based on the input the user has provided on the hyperlink. The next block of code, simply provides the setup for the User Profile Service so that we are able to access the current users profile.



Once we have the profile object we are then able to retrieve the collection of value’s that are currently stored in the user property we created earlier.



The property is actually returned as collection, rather than a delimited set of strings, so we can quite easily iterate over the collection, and then compare whether the stored data (i.e. set of URLs) match the URL of the current site, and therefore indicate the user is following the current site.



We now have most of the functionality we need, the missing piece is simply to add or remove objects from the collectionofPropertys that we have retrieved above based on our previous bool. The first check we therefore do is to whether the followMe bool is true.



If the value is true, then we toggle isFollowing to true, so our hyperlink is configured correctly, and then simply add the URL to our collection of strings in the user profile, finally committing any changes. The inverse is almost as simply, however to remove values you must know the index of that particular value in the collection, so we must first iterate over the collection, find the location of the matching URL and then remove it and commit as show below.



If all has gone successful you will have a fully functional hyperlink that toggles values when you select it:

2012-09-07-AddingFollow-04.png

If you then head over to the USPA and look at the user profile via central admin, you will see the URLs populated:

2012-09-07-AddingFollow-05.png

Now that this functionality is working, you simply need to display a listing of sites a user is following, all the code required is above, in my environment I created a web part, setup the connection to the USPA, grabbed the collection of property’s similar to this article and iterated over the values, opening the URLs and display the title of the site, the end result looked something like this:

2012-09-07-AddingFollow-06.png

The entire block of code for the functionality is below:



What does SharePoint 2013 mean to the Visual Studio Developer Ninjas?


You may also be interested in: O’Reilly - SharePoint 2010 at Work


 

2012-07-27-Ninjas-01.jpgJeff Teper has concerned some community folk after Mike Watson posted something in the SharePoint Yammer community that pointed to a comment made around “Use SharePoint as an out-of-box application whenever possible…I’ve seen many SharePoint deployments where they would have been better off out of box and with the new UI we want to be really clear on that”. Wictor Wilen (MCM, MVP) made a great comment on this “that blog post and statement will be with us for a long time and for us dealing with clients the "We encourage you not to modify it […]" will really impact the business for SharePoint 2013”. And the definition of “out-of-the-box” is not restricted to just Visual Studio Development…we are talking JavaScript and HTML 5 tinkering too…all put the UI at risk for upgrades and operation supportability which is where Jeff is coming from.

Jeff does state “there will also be places where people write code which we want to support better in the new model but also want to encourage folks to be thoughtful about their code”…I’m kind of taken a back here. We’ve always been thoughtful of any customization…but the problem is…the platform can be customized and as much as you push back on customers asking for changes to the UI…they’ll pay for it and won’t care on your warnings. I for one am scared of the new NAPA framework, introduced by Jason Zander, that easily lets power users put together JavaScript code to manipulate the UI…that is Pandora’s Box a lot more so than SharePoint Designer in my opinion.

“ASP.NET is dead”

Doug Ware (MVP) has written up a great post on his opinions on what the new SharePoint 2013 preview means for developers. I think he’s a bit bold in saying “ASP.NET is dead”, considering the new remote-hosted app model encourages you to build web applications remotely from SharePoint platform.

To Doug’s point, a lot of the new UI stuff is back-ended by some pretty slick JavaScript and HTML5 elements in the 15 hive (root folder/whatever you want to bloody call it!). I’ve been saying for a long time, and to be honest, joined this march late…considering Marc Anderson (of SPServices fame) has been banging the JavaScript drum for a long time. As a managed code guy, I hated the thought of coding in client side language, one article that really helped me was by a British guy called Ben Padbury.

Getting you off of server-side object model

Ted Pattison also makes some good comments about Microsoft wanting to get you off server-side object model, mainly because Microsoft don’t want your code running in processes running on the SharePoint farm and therefore increasing the stability…especially for their Multi-Tenancy Office 365 environments. Ted also states the other reason is that the server-side object model was often a pain when upgrading to the new major version of SharePoint. I’m not necessarily sure that moving the customizations out to the new App model is going to solve this…after all, they are still going to be calling the client-side object model and that will change. Vendors are already witnessing issues as Office 365 SharePoint Online has updates that are affecting the expected results back from the client-side object model.

You can still write in server-side managed code in the new Apps…although you will be coding against the SharePoint .NET client-side object model and not the SharePoint .NET server-side object model, as you won’t be executing the code on the SharePoint server but a remote one (either Azure or something else). The only way now to write SharePoint .NET server-side object model managed code is to stick with Full-Trust solutions OR Sandboxed Solutions (limited) which unfortunately WON’T be in the marketplace.

Doug also points out that SharePoint 2013 preview also is now on .NET 4.0 rather than 3.5. I completely understand why the product team didn’t do this in the 2010 release as .NET 4.0 release dates were almost in parallel. The only product team brave enough to do that was the Project Server team who built in parallel to SharePoint Server 2010. Stephane Eyskens’s blog has a great overview of some of the .NET 4.0 features that you probably haven’t even looked at before with your Visual Studio hat on. So if you do write with the Solution model, you can now use .NET 4.0.

Who has the bucks for business solutions?

Rob Windsor (MVP) also makes a great point that “all bets are on” in the cloud for Office 2013 and that the “Solution model” (e.g. Full-Trust Solutions and Sandboxed Solutions) are being treated as deprecated features in this platform based on the voice of the TechNet and MSDN articles being published around the App model on “getting started with SharePoint 2013 development”. I do tend to agree, and have already voiced my concerns that the majority of EPG customers that are going to want to pay for development won’t be in Multi-Tenant environments and will be in Full-Control environments. Therefore in most cases, Full-Trust solutions will make sense.

Also, remember that the App model for Full-Control environments does not support OAuth because it doesn’t support Azure’s Access Control Services (ACS), so you have to use High-Trust apps which come with some more complexity.

Future-proofing environments

The debate on whether to “future-proof” environments for Multi-Tenant becomes HUGE. Eventually I think the cost that was incurred in future-proofing business solutions by building them as Sandboxed Solutions rather than going with Full-trust Solutions burnt a lot of people. The reason for this is because the effort involved to code around limitations of Sandboxed Solutions was extremely high and in some cases simply couldn’t be done putting limitations on business solutions. I suspect a lot of large EPG customers will continue to push with Full-Trust Solutions with the mindset that they’ll be in Full-Control environments for a long time to come.

Doug has also pointed out in another post another statement that is reminiscent of the Sandboxed Solution introduction of “develop X whenever you can”. The reality is if you already know how to smash out a Full-Trust Solution, why take the time to learn how to build Apps, much like the argument we had on learning Sandboxed Solutions.

More competition

Where Visual Studio SharePoint Developers were raking in the bucks in 2007 and 2010 world…I believe this shift to the App Model will definitely make the market more competitive. As people with HTML5/JavaScript, ASP.NET MVC, LAMP etc. skills will now be able to build remote-hosted web applications and build a very simple app package to point to this that can be submitted to the marketplace. The only learning curve for them is going to be the SharePoint client-side object model and some understanding of the building blocks available to them in the app subsite such as Lists/Libraries and everything that comes with that. This won’t happen instantly, but I used to work at a very strong .NET house that loathed SharePoint, and can now see them happily building EVERYTHING in the remote web application with very little integration and getting it in the marketplace.

Wrap Up

So as a Visual Studio SharePoint Developer writing on server-side SharePoint object managed code…personally I think you have no choice but to get your teeth into JavaScript/HTML5 and the SharePoint Client-Side Object Model if you haven’t already. This new wave will certainly put pressure on you, I don’t see EPG customers jumping to Multi-Tenant environments straight away but you can certainly bet in the next two years it’ll start to happen and the server-side object model won’t be an answer.

Please make sure you check out my social bookmarks on all things SharePoint 2013 and development and if that’s too much, try my 5 star rated posts sub set.

Geo location Field in SharePoint 2013


You may also be interested in: Smartdesk Advanced ECM Apps


 

Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

Last year I wrote a series of articles on a mash up between a SharePoint list and Bing Maps, it was a three part article and took quite a lot of time to get the end result.

Thankfully in SharePoint 2013 Preview, Microsoft has added the functionality in to achieve this fairly easily. This is achieved with a Geo location field. This field stores location information i.e. Longitude/Latitude which can then be rendered on a Bing/Nokia Map. The one downside is that you’re going to need to crack out Visual Studio 2012 in order to add this field, or at least this is what the examples say on MSDN. Hopefully this is added in to the interface by release, I couldn’t find it anywhere however.

Before you get started sort out the following pre-reqs:

  1. SharePoint 2013 Preview Farm
  2. Visual Studio 2012
  3. Bing Maps API Key Available Here

The first stop is to register the Bing Maps Key against SharePoint; you can achieve this using PowerShell with the following command:

Set-SPBingMapsKey –BingKey ““

You can also do this via code see how here. This will make it easy if you’re packaging up an application that takes advantage of these features.

The next thing to do is to add a new custom list, in this example I have created one called “Office Locations”. In this example I have renamed “Title” to “Name” and added an “About” column of type multi-lines of text.

When you’re done the list should look similar to the following:

2012-07-23-GeoLocation-01a.png

Open up Visual Studio 2012 and create a new Console Application, in this example I have just given it a name of AddGeoField.

 2012-07-23-GeoLocation-02.png

The first thing we need to do is add assembly references to the two following dll’s:

  • Microsoft.SharePoint.Client.dll 
  • Microsoft.SharePoint.Client.Runtime.dll 

2012-07-23-GeoLocation-03.png

Open the class (.cs) file and add a using statement at the top of the file:



Now we need to add the code to the console application I have made this generic to read in the arguments, this way we can reuse the same console application anywhere in our farm.



Build the solution and then run the application from the command line, replace the arguments with ones relevant to your environment. Make sure the account your running under has sufficient permissions to access the site collection/web/list.

AddGeoField.exe http://sp2013 “Office Locations”

Now if we go back to our list, we can see the Location column has been added of type Geolocation.

2012-07-23-GeoLocation-04.png

When adding a new item, we can either use the current location which will be useful for devices with GPS built in, or add the longitude/latitude of the current location.

2012-07-23-GeoLocation-05.png

When you click specify location, a second modal popup opens where you can specify the values required:

2012-07-23-GeoLocation-06.png

Once valid values have been entered, a Bing map preview is displayed to give you a indication that you have the co-ordinates correct.

2012-07-23-GeoLocation-07.png

After adding a few office locations, the list will look similar to the following:

2012-07-23-GeoLocation-08.png

You can view the Bing Map in various ways:

  1. Opening a list item:
  2. 2012-07-23-GeoLocation-09.png

  3. Clicking on the 2012-07-23-GeoLocation-13.pngicon in the geo location field, this is a great way for a fast preview:
     
  4. 2012-07-23-GeoLocation-10.png

Lastly, you can also now create a map view, if you create a new view, you will see a Map View type.

2012-07-23-GeoLocation-11.png

When I was creating my view I got an error, but the view created anyway, when you switch to it you get a awesome representation of all the list items.

2012-07-23-GeoLocation-12.png

I think you would agree this is a lot easier than what we had to do in previous versions of SharePoint. I would love to see uses you can come up with when you put this in to practice.

If you want to save some time I have uploaded my compiled solution for you to use: Add Geo Location (5)