Facebook Page

Posted by Troy on August 7, 2010 under Blogging, Business, Business Intelligence, IT, Microsoft, Performance Management, Social Networking | Be the First to Comment

Well I am not sure how much sense it makes for a Blog to have a Facebook Page but I though I would try it out.  I am always looking for new topics or issues to write about especially in the area of Business Intelligence or even day to day question on how to use Microsoft Office and SharePoint to enhance business activities.  Feel free to post ideas or comments. 

 

Troy Scott – Blog

Promote Your Page Too

BDC Models in Visual Studio 2010 for SharePoint Foundation Server 2010

Posted by Troy on under csharp, Microsoft, SharePoint, SQL Server, Visual Studio, Web | 5 Comments to Read

When I first started building External Content Types in (ECT) SharePoint Foundation Server I used SharePoint Designer.   SharePoint Designer is a good place to start if you are learning how build ECT’s.  It does not require any .NET code and you can build a fairly decent application in little time especially if you have a solid relational database background.  But I wanted to try build an External Content Type using Visual Studio 2010.   In this case I am going to build a simple BDS Model based on the SalesLT.Customer table in the AdventureWorksLT2008R2 database.

First, lets start by creating an empty SharePoint 2010 Solution (C#)  in Visual Studio 2010.  Select File > New > Project from the file menu.  In the Installed Template section under Visual C# > SharePoint > 2010 select the Empty SharePoint Project and name the project SPDev1.  This will create an empty SharePoint project which we can add multiple projects to.

image

When you select Ok the SharePoint Customization will be displayed.  Enter the the site you want to use for debugging the project and make sure you select “Deploy as a farm” solution:

image

Right-click on the SPDev1 project and select Add New Item:

image

Now Select Business Data Connectivity Model from the Add New Item list and name it AWLTCustomer.  Once you enter the name of the model click Add:

image image
Add BDC Item BDC Solution

When the BDC Model is added it is fully functional.  If you Build the project it will compile without any errors. 

You will notice that I named the Blog Post “BDC Models in Visual Studio 2010 for SharePoint Foundation Server 2010”  and not “BDC Models in Visual Studio 2010 for SharePoint Server 2010”  .  If you created this project using SharePoint Server 2010 you can actually deploy this project to the debug site and it will create an BDC Model with an entity called Entity1.  But if you are using SharePoint Foundation Server 2010 you will receive the following error when the project is deployed (Right-click the project and click Deploy):

Error    1    Error occurred in deployment step ‘Add Solution’: Failed to load receiver assembly "Microsoft.Office.SharePoint.ClientExtensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" for feature "SPDev1_Feature1" (ID: 1a75169a-e716-4d4b-a43c-3c0cf032fc40).: System.IO.FileNotFoundException: …

In order to deploy a BDC Model to Foundation Server a Feature Event Receiver is required to publish the mode to the site:

Publish BDC Model project to SharePoint Foundation 2010 with Visual Studio 2010

The following post on one of the Microsoft Blog sites provides details on how create the Feature Event Receiver. 

Deploy a BDC Model project to SharePoint Foundation 2010 using Visual Studio 2010

Basically you need to download the following file from the first link:

Feature Event Receiver (C#) 

In the current project, add an Event Receiver to Feature1 by right-clicking Feature1 and select Add Event Receiver:

image 

First copy the existing content of Feature1.EventReceiver.cs to a file using notepad.  Next, replace the contents of Feature1.EventReceiver.cs with the contents of the file downloaded from the Microsoft site (FeatureEventReceiver.cs) (Ctrl-C, Ctrl-V).   The details from this point on can be found in the Microsoft Blog post mentioned above (Deploy a BDC Model project to SharePoint Foundation 2010 using Visual Studio 2010), but I will provide some additional screenshots along with the steps.

We need to Add a reference to the MicrosoftBusinessData.dll. In order to do this you have to copy the dll from the GAC.    Click Start > Run and enter the following:

  • C:\Windows\assembly\gac_msil
image image

 

Find the Microsoft.BusinessData folder and copy the Microsoft.BusinessData.dll to the following folder:

  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI

Next add the following references to the project:

image image
System.Web Microsoft.BusinessData.dll

Set the BDC (SharePoint item property) which in our case is located in the AWLTCustomer model and set the following properties located under Feature Receiver Category:

  • Assembly = Assembly = $SharePoint.Project.AssemblyFullName$
  • Class Name = SPDev1.Features.Feature1.ImportModelReceiver
image image
Properties Before Properties After

Set the Feature property by double clicking on Feature1.Feature and update the following property:

  • Receiver Class = SPDev1.Features.Feature1.ImportModelReceiver
image image
Properties Before Properties After

One last thing, we need to change the Namespace of the code that was copied into Feature1.EventReceiver.cs from BDCModelReceiver to SPDev1:

image 

I have been writing this post while following  Microsoft Blog.  So, here is the moment of truth.  After the last step we should be able to deploy the BDC model.  Right-click on the project and click deploy or click F5 if you want to debug the solution.  To view the content type you can open SharePoint Designer and navigate to the External Content Type sit object:

image

Before you can create an External list based on the new External Content Type the permissions must be set.  Check out this post for setting the permissions using the SharePoint Central Administration site:

Setting Permissions for an External Content Type

Once the permissions have been set an External List can be created.  In this example the External List is very basic and in fact the model has not been connected to the External table in the Adventure Works.   But that is a topic for another post.

For more information on BCS check the Microsoft BCS Team Blog:

http://blogs.msdn.com/b/bcs/

 

Troy

Cannot start service SPUserCodeV4 on computer

Posted by Troy on August 6, 2010 under .net, IT, Microsoft, SharePoint, Visual Studio, Web | Read the First Comment

This week I was creating my first SharePoint 2010 Sandboxed solution using Visual Studio 2010.  I have successfully built and deployed other SharePoint projects on the server but I always used Farm based solution due to the requirements.

When I built the Sandboxed solution the project would build and package without any errors but when I tried to deploy it to the SharePoint site the following error occurred:

Error    1    Error occurred in deployment step ‘Activate Features’: Cannot start service SPUserCodeV4 on computer ‘SERVERNAME’ 0    0    SP2010Dev1

The error can be easily resolved by starting the Microsoft SharePoint Foundation Sandboxed Code Service which can be accessed through the Central Administration site in SharePoint.   Open the Central Administration site and go to System Settings and click on Manage Service on server:

image

Check to see if Microsoft SharePoint Foundation Sandboxed Code Service  is running, it should be stopped :

image

Start the service and try deploying the Sandboxed solution.

Thanks to Sergey Hyper Kravchenko for his post on the MSDN SharePoint discussion forum:

error occurred in deployment step ‘retract solution’ cannot start service SPUserCodeV4 on this computer

Troy

Running Visual Studio 2010 as Administrator

Posted by Troy on August 5, 2010 under .net, IT, Microsoft, Visual Studio | Be the First to Comment

If you are using Windows 7 or Windows Server 2008 and you try to create a project once Visual Studio has been opened you may receive the following message:

This task requires the application to have elevated permissions

image

If this occurs you have two options:

Right-click on the Visual Studio 2010 Shortcut

Hold down the SHIFT key and right click the shortcut:

image

Select Run as administrator and when you try to create project it will work.   The downside of this approach is that you have to do this every time you want to run Visual Studio.

Set the Visual Studio Shortcut Properties to Run As Administrator

Hold down the SHIFT key and right click the shortcut:

image 

Select properties and then click on the  Compatibility tab.  In the Privilege level section select the Run this program as an administrator check box.

image 

Click Apply and when you double click the shortcut next time the program will run with Administrative privileges.   However, you will receive a User Account Control notification when the program is run:

image

Troy

Modifying the View of an External SharePoint List

Posted by Troy on July 19, 2010 under Business, Business Intelligence, Microsoft, Performance Management, SharePoint, SQL Server | Be the First to Comment

If you have been following along in the last few posts,  I have created an External Content Type called BcsSalesForecast with the following operations:

  • Read List
  • Read Item
  • Update

Then an External List was created called Sales Forecast 2010.  Up to now the main focus of the discussion has been around creating the External Content Type and the store procedures which are used as its data source.  However, if you currently view the list below its presentation as a lot to be desired.  First off, its sorted by ID and there are over 700 records with 30 per page which means that it could take awhile to find the record you are looking for.  

In order to make the list more “useable” it is possible to modify the view.   Before the view is modified a minor update is required to the data.  The Sales Forecast 2010 list is a weekly forecast application for 2010 and provides the previous years as a starting point (the data is actually from Adventure Works for 2008).    Ideally it would be nice to sort the data by week but I did not include a sort key as part of the original design.   But this can fixed by running the following UPDATE statement against the dbo.WeeklySalesForecast table:

update dbo.WeeklySalesForecast set WeekNumber = case when CONVERT( INT,SUBSTRING(WeekNumber,5,3)) < 10 then 'Week 0' + SUBSTRING(WeekNumber,6,1) else WeekNumber end

This will  add a leading 0 to all weeks that are less then week 10 which will ensure the sorting by Week will work.  Now you can navigate to the Sales Forecast 2010 list and click on the List tab:

image

Next  click Modify View but do not click on Modify in SharePoint Designer (Advanced).  For this scenario SharePoint 2010 Designer is not required.  The changes to the list can be performed in the browser.  Change the First Sort Column from ID to WeekNumber:

image

Next set the First Group By Column to SalesRegion and the Second Group By Column to ProductCategory:

image

Change the number of items to display per page from 30 to 300 :

image

Hide the SalesRegion and ProductCategory since these are redundant because they are being used as Groups. Secondly the ID field can be hidden because it is just required as the unique identifier for the row:

image

(Note: the position of the columns may be different than what you see when you “Modify” the view)

Click OK to save the changes to the view and now look at the List:

image

As you can see, a few simple modifications to the list can make a significant difference in terms of the lists usability.

Troy