in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

This Blog

Syndication

All About SharePoint - S.S. Ahmed - MVP Microsoft SharePoint

All About SharePoint, as the name suggests, is all about SharePoint. It has articles, tutorials, source code, FAQs, and tips about SharePoint, InfoPath, C#, Microsoft Office, SQL Server, XML, etc.
  • XPath, XQuery, and XSLT Functions

    Some XML functions can be very useful in InfoPath, especially if you are an InfoPath developer. For example, suppose you are using data validation in your InfoPath form and you want the users to enter a value in one of the text boxes on your form. Of course, you can use the built-in data validation functions, for example, "If field is blank then show error alert" but users can dodge you by entering a space in the text box. In this case, InfoPath won't generate any error and will accept the value entered by the user. How can handle this situation? The answer is XML functions. You can use normalize-space() function. Right click the control and select "Data Validation". In the drop down, select "The expression" and in the text box enter normalize-space(.)="". In the screen tip, enter "Please enter valid value" and click Ok. InfoPath will now show an error if users try to enter an invalid value like a whitespace. Similarly, you can use other XML functions in your code or to validate data using the built-in data validation. More functions can be found on the following page. The page has the list of functions and examples to show how each function works:

    http://www.w3schools.com/Xpath/xpath_functions.asp

    -SSA

  • How to grant permissions to a custom assembly that is referenced in a report in Reporting Services

    It seems straight forward. Isn't it? but it may not be as simple and straight forward for the newbies as it seems at first. A colleague and a  friend of mine recently was struggling with the same issue and he learnt the lesson after spending considerable amount of time experimenting with different solutions. You get a security exception when you write your own component to be used in a report in reporting services. My friend is working on a SharePoint project that involves reporting services. He created a report that used a custom built component. The code used SharePoint object model. He tried to use Elevated privileges but even that didn't work because the error is thrown on the line that has the elevated priviliges code. He even tried the code access security, that didn't work. The following KB article has information about this problem:

     http://support.microsoft.com/kb/842419/ (How to grant permissions to a custom assembly that is referenced in a report in Reporting Services)

    Use following code to get rid of the security exception:

    SharePointPermission perm = new SharePointPermission(PermissionState.Unrestricted);
    perm.Assert();

    //Code using SharePoint object model here!!

    perm.Deny();

    Include following DLL in the references before you use the above code:

    Microsoft.SharePoint.Security.DLL

    This DLL will be found in the 12 hive. Exact location is as following:

    System Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\

    Add following namespaces at the top:

    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Security;
    using System.Security.Permissions;

    That's it. Your component will now work fine.

  • MVP Summit experience

    Returned from the summit on friday night but my body was so sour that I spent whole saturday sleeping, relaxing, and watching TV. This was my first summit experience and undoubtedly it was the best experience I have had in recent times. This was the first time I met SharePoint MVPs in person. I have uploaded some pictures that I took during the summit, here are the URLs:

    http://picasaweb.google.com/saifullah.shafiq/Paintball2008
    http://picasaweb.google.com/saifullah.shafiq/PartyWithPalermo
    http://picasaweb.google.com/saifullah.shafiq/MvpAttendeeParty
    http://picasaweb.google.com/saifullah.shafiq/ProductGroupDinner
    http://picasaweb.google.com/saifullah.shafiq/PaintballLunch

    The sessions were very informative and I got chance to spend some quality time with the other MVPs during the events like Paintball, Attendee party, PG dinner, etc. I also got chance to meet with MVPs from around the world. All in all, it was an excellent experience and I really enjoyed the visit and I hope to visit the summit again next year which is expected to start on March 1st, 2009. Those of you interested in finding out how we SharePoint MVPs had fun at the summit may want to read the following blog post:

    SharePoint MVPs know how to have fun .. and give constructive product feedback

    -Saif

     

     

  • MVP Renewed!

    My MVP award has been renewed for another year. I am very happy and very excited because I have lots of interesting plans this year. I would like to thank all my well wishers and readers who read my blog and articles and send positive feedback and comments. Thank you!

     -SSA

  • External Collaboration Toolkit for SharePoint released

    External Collaboration Toolkit for SharePoint has been released and can be downloaded from http://www.microsoft.com/collabkit. The toolkit runs on MOSS 2007 and WSS 3.0.

  • SharePoint Capacity Planner Tool is now available for download

    You can read about the SharePoint Capacity Planner Tool on the following page:

     http://technet.microsoft.com/en-us/library/bb961988.aspx

    You can download the tool from the same page or download it directly from the following page:

    http://www.microsoft.com/downloads/details.aspx?FamilyId=DBEE0227-D4F7-48F8-85F0-E71493B2FD87&displaylang=en

    You can download the System Center Capacity Planner 2007 from the following link:

    http://www.microsoft.com/systemcenter/sccp/default.mspx

    The direct link to download the System Center Capacity Planner 2007 is as follows:

    http://www.microsoft.com/downloads/details.aspx?FamilyId=E754F35D-59DB-4BC4-8386-E83E66A16FAD&displaylang=en

    -SSA

     

  • SharePoint and MySQL

    SharePoint and MySQL
    Integrating SharePoint with MySQL using Business Data Catalog

    This is another article of the same series that has been continuing for the last couple of weeks. Yep! SharePoint and the Business Data Catalog! Following are the recent articles that cover the SharePoint and the Business Data Catalog "Definition Editor Tool":

    1. Working with Business Data Column
    2. Importing BDC Data into SharePoint
    3. Using Business Data Catalog Definition Editor
    4. Few Issues With Microsoft Business Data Catalog Definition Editor

    In this article, we will discuss how to integrate SharePoint with MySQL database using the Business Data Catalog. We will use the "Business Data Catalog Definition Editor Tool" to create the application file. There has to be a way to connect SharePoint, one of the world's best collaboration portal products, and the MySQL, the world's most popular open source database (as claimed by the MySQL team). SharePoint allows users to index and search data in Line-of-business (LOB) applications.

    I used MySQL version 5.0 for this demo.

    Create a database

    Create a database named "musicrecords". This database has 1 table "albums" and "albums" has following fields (See Figure 1):

    MySQL table description

    Figure 1: Table "albums"

    Field names are: name, artist, dateofrelease, numberofsongs, id

    Install ODBC Driver

    You will also need to download the ODBC driver from the MySQL site. ODBC 5.1 is a newer version and has improved performance as compared to the older 3.51 version. After downloading, Install the driver on your system. Installation is easy. Wizard guides you through the setup process.

    Install the ODBC 5.1 Driver

    Figure 2: Install the ODBC 5.1 Driver

    Configure ODBC Driver

    After installing the ODBC driver, you have to add a system DSN. Following are the steps required to add the DSN:

    1. Go to "Data Sources". In Windows 2003, Select "Start > Administrative Tools > Data Sources (ODBC)".

    2. Select the "System DSN" tab.

    3. Click the "Add" button.

    4. Select "MySQL ODBC 5.1 Driver" from the drivers list and click "Finish".

    Select the driver from the list

    Figure 3: Select the driver from the list

    5. Add a data source name and description. Data source name and description can be anything but for this demo, use "dsnMusic" as the data source name. This is because we have used this name in the "XML definition file". Add server name. By default, the server name is "localhost" and the port is "3306".  If you configured your server on a port other than the default "3306", enter it in the "Port". Enter user and password. Entering correct user and password is important to connect to the database. If you entered correct user and password, the database drop down will fill with the databases that the user has permissions to access. Select the database, in our case, select "musicrecords" and click "Test". If everything is ok, it will show you "Connection successful" message. These are the basic settings. You can also configure the DSN for other settings like the SSL, log information, etc. To configure other settings, click the "Details" button. It will show you five tabs: Flags 1, Flags 2, Flags 3, Debug and SSL Settings. For this demo, configuring other settings is not required.

    Configure ODBC Driver settings

    Figure 4: Configure ODBC Driver settings

    Create Definition File

    6. Open "Microsoft Business Data Catalog Definition Editor". Click "Add LOB System".

    7. Click "Connect to Database".

    8. Select "ODBC" from the "Connection Type" drop down.

    9. Enter "dsn=dsnMusic;Trusted_Connection=True" in the "Connection String" box and click "Connect".

    10. Click "Add Table" button which is visible on the right side vertical bar.

    11. You will see only one table "albums" in the list. Drag and drop that table to the middle.

    12. Click "OK". Enter a name for the new LOB system. I had named it "musicrecords". Click "OK". You will see "Creating LobSystem" message in the status bar. It will take a few seconds to create the LOB system. You will see "Ready..." in the status bar once the LOB system is ready.

    13. Let's test the new LOB system. By default, two new methods will be added: "Find_albums" and "FindAll_albums". Expand the "FindAll_albums" node, double-click "Instances" folder. Right-click "FindAll_albums_Instance" and select "Execute". Click the "Next" button to execute the method. You should see the following error message (See Figure 5):

    The LobSystemInstance Property 'AuthenticationMode' 
has a value that requires 'Trusted_Connection' in the connection string.

    Figure 5: The LobSystemInstance Property 'AuthenticationMode' has a value that requires 'Trusted_Connection' in the connection string.

    14. Close the window. Go up and open the "Instances" folder just under the main node "musicrecords". Click "musicrecords_instance". Click any where inside the connection string box, a button will appear, click it. It will open a box where you can edit the connection string.

    Edit the connection string

    Figure 6: Edit the connection string

    Copy and paste the following connection string in the box and click "Ok":

    data source={
    "Driver={MySQL ODBC 5.1 Driver}};dsn=dsnMusic;Uid=root;Pwd=admin;Trusted_Connection=true;"}

    Do not try to align or format this string, copy it as it is. Change the user id and password. By default, the user id is "root". If you are using a different user id, replace the "root" with your own user id. Also, change the password.

    Now try to execute the method "FindAll_albums_Instance" again and see if it works. It shouldn't work! You will get the following error message (See Figure 7):

    The field named "id" is defined 
by the Entity as being of Type 'System.Int32', but the back end system returned 
a value of Type 'System.String'

    Figure 7: The field named "id" is defined by the Entity as being of Type 'System.Int32', but the back end system returned a value of Type 'System.String'.

    To fix this error, click the method name "FindAll_albums". Do not confuse it with the method instance name which is "FindAll_albums_Instance". In the properties section (in the right side pane), modify the "select" statement in the "RdbCommandText" property. Click inside the property box, a  button will appear, click this button to modify the "select" statement. Clicking the button will open a box named "wideTextBoxEditor". You can edit the statement in this box. You can also edit the statement directly in the property box without opening this "wideTextBoxEditor". The statement will be as following:

    select "id" from albums

    Remove the double quotes around the "id". The statement now should look as follows:

    select id from albums

    Now, select the method instance "FindAll_albums_Instance", right-click it and select "Execute". Click "Next". It will show you the IDs available in the table.

    Now, let's turn towards the "Find_albums_Instance" method. Right-click the method name, click "Execute". You will be required to enter the input parameter which will be an existing id. Go ahead and enter an id that you know exists in the database. Click "Next". What will happen? Will it show you the record? No! It will give you the following error (See Figure 8):

    LOB system did not find instance

    Figure 8: LOB system did not find instance

    Great! Let's fix this issue. Click on the "Find_albums" method. In the right side "Properties" pane, You will see the following SQL statement in the "RdbCommandText" property:

    Select "name","artist","dateofrelease","numberofsongs","id" from albums where id=@id

    Remove the double quotes around the select parameters and replace the input parameter "@id" with "?". The statement after modification will look as following:

    select name,artist,dateofrelease,numberofsongs,id from albums where id=?

    Now, let's test the method instance "Find_albums_Instance" again. Right click the instance name and select "Execute". Enter an ID that you know exist in the database and click "Execute". The result will be shown in the "Results" grid.

    Results grid showing the record 
retrieved against the ID provided as input

    Figure 9: Results grid showing the record retrieved against the ID provided as input

    Adding A New Method

    15. Let's add a new method that will return all the records. Right-click the "Methods" node and select "Add Method". This will add a new method "Method0". Click the method "Method0" and change it's name in the properties pane. Give it a meaningful name, for example, "FindAll_album_Records". Click anywhere in the "DefaultDisplayName" property, it will automatically acquire the new method name you just entered in the "Name" property. In the "RdbCommandText" property, add the following statement:

    select * from albums

    Right-click "Parameters" node, and select "Add Parameter". You will see following four options:

    a. In
    b. InOut
    c. Out
    d. Return

    Select "Return" and click "Ok".

    Select a return parameter

    Figure 10: Select a return parameter

    Rename the newly added parameter from "Parameter0" to "@albums". To rename it, change the "Name" property. After changing the "Name" property, click anywhere in the "DefaultDisplayName" property to change it to the name you just entered. Right-click the new parameter "@albums" and select "Create Root Typedescriptor". Change the "Name" and "DefaultDisplayName" of this type descriptor from "@albums_RootTypeDescriptor" to "Reader". Right-click root type descriptor "Reader" and select "Add TypeDescriptor". Change "Name" and "DefaultDisplayName" of this type descriptor from "TypeDescriptor0" to "Record". Right-click "Record" and select "Add TypeDescriptor". Change the "Name" and "DefaultDisplayName" to "name" which is one of the table fields. Similarly, for the remaining fields (artist, dataofrelease, numberofsongs, id), add a type descriptor for each field and change it's "Name" and "DefaultDisplayName" properties to its actual name. chFor example, for the field "numberofsongs", change the "Name" and "DefaultDisplayName" to "numberofsongs". Well, it's up to you. If you want to give some other name to your field, add it in the "Name" and "DefaultDisplayName" properties. Field "id" requires special attention. Change its "TypeName" from "System.String" to "System.Int32". Click anywhere in the "Identifier" property, a drop down will appear, select "id[albums]" from the drop down (See Figure 12).



    Figure 11: "FindAll_Album_Records" Method
     
     
    Figure 12: Change "Identifier" property

    Right-click "Instances" and select "Add Method Instance". It will show you "Create Method Instance" interface. Select "Finder" as the method instance type. Click "Ok". Change the method instance name and default display name from "MethodInstance0" to "FindAll_album_Records_Instance".

    "Create Method Interface" 
screen

    Figure 13: "Create Method Interface" screen

    To test this method instance, right-click the instance name and select "Execute". Again, click the "Execute" button. All the records in the table will be shown in the "Results" grid.

    Figure 14: "Results" grid showing all the records from the database

    Final Step

    16. Before the application could be imported into the SharePoint, there is one last step remaining. Click the main node "musicrecords" in the tree view and enter "%" in the "WildcardCharacter" property (in "Properties" pane on the left). Without this your application instance won't appear in the web part's tool pane.

    Using BDC Application In SharePoint

    17. To use the newly created application in SharePoint, export the LOB system to XML file by selecting the main node "musicrecords" and clicking the "Export" button. Enter a name for the XML file. I used "musicrecords". Click "Save" to save the file on your system.

    18. Go to SharePoint Central Administration and open SSP defined for the site where you want to display BDC data.

    Select Shared Services Provider in SharePoint Central Administration

    Figure 15: Select SSP in SharePoint Central Administration

    19. Click "Import application definition" (Business Data Catalog section).

    20. Click "Browse" and select the definition file. Click "Import" button. Do not change other options on this page. File Type should be "Model".

    21. Now go to your SharePoint site. Select "Edit Page" from "Site Actions".

    22. Click "Add a Web Part" in the zone of your choice.

    23. Select "Business Data List" web part from the list of available web parts. If this web part is not available, then you will have to add it first to the list. Select "Site Settings" from "Site Actions". Go to Top level site settings if this is not your top level site. Select "Web parts" from "Galleries" section. Click "New". Select "BusinessDataListWebPart" (See File Name column in the list) and click "Populate Gallery". Now go back to the site. Select "Edit Page" from "Site Actions". Click "Add a Web Part" in the zone of your choice.

    24. Select "Business Data List" from the list of web parts and click "Add".

    Add Business Data List Web Part

    Figure 16: Add Business Data List Web Part

    25. Click the "Open the tool pane" link in the web part.

    Select Business Data Type

    Figure 17: Select Business Data Type

    26. Click the browse button and select the BDC Type. Click "Ok".

    27. The BDC web part will display the data retrieved from the database. See following figure to see how the data looks like.

    BDC data in a web part

    Figure 18: BDC data in a web part

    That's it. We saw how we can use the Microsoft Business Data Catalog Definition Editor tool to create the application file needed to connect SharePoint with MySQL.

    Click here to view the BDC Application file (musicrecords.xml).

    Click here to download the BDC Application file (musicrecords.xml) in zip format.

  • Office SharePoint Designer 2007 Step by Step, is now in the book shops

    Microsoft Office SharePoint Designer 2007 Step by Step is now available in the market. The book targets the Information workers. Introduction of the book can be read on the author's (Penny Coventry) blog:

    http://mindsharpblogs.com/penny/archive/2008/01/20/4184.aspx

    Microsoft site also has some details on the book:

    http://www.microsoft.com/mspress/books/12083.aspx

    I will post a review of this book as soon as i get a copy.

    -SSA

  • Links for Workflow with VS 2008

    People have already started blogging about the workflow creation with VS 2008. Here are a couple of cool links that show how to create sequential workflows using VS 2008:

    SharePoint Workflow Feature in VS 2008

    Screencast:

    How to Video: Building a basic Approval Workflow with SharePoint (MOSS 2007) and Visual Studio

    Webcast:

    Advanced SharePoint Document Workflow with Visual Studio 2008

    Also, do read the following good article about VS 2008 written by Dino Esposito:

    Inside Visual Studio 2008

    -SSA

  • InfoPath Error: The given key was not present in the dictionary.

    If this error occurs when you try to submit the form, then there can be two reasons for this. The data connection name is not correct or the URL used in the data connection is not correct. Sometimes, it is hard to pin point the problem because the URL will not be accepted if it has a problem, no matter how minor. An extra space, an illegal character, etc are the problems that are hard to locate and are the source of this error. This usually occurs when you try to submit the form programmatically because directly publishing the form to the SharePoint allows you to select the site and library so there is no chance of entering a malformed URL but when you submit the form programmatically using a data connection, you have to provide the URL manually. The details of the error are as follows:

    ------------------

     The given key was not present in the dictionary Source: Microsoft.Office.InfoPath.Server Stack trace:   at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.ExecuteOMCallWithExceptions(OMCall d, ExceptionFilter exceptionFilter)
       at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, ExceptionFilter exceptionFilter, OMCall d)
       at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, OMCall d)
       at Microsoft.Office.InfoPath.Server.DocumentLifetime.DataConnectionCollectionHost.get_Item(String name)
       at function() in Path\code.cs:line 394
       at function() in Path\code.cs:line 290Location:Void ExecuteOMCallWithExceptions(Microsoft.Office.InfoPath.Server.DocumentLifetime.OMCall, Microsoft.Office.InfoPath.Server.DocumentLifetime.ExceptionFilter)

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

    ---------------------------

    Code to submit form programmatically:

     public void FormEvents_Loading(object sender, LoadingEventArgs e)
     {
           string srcLoc = e.InputParameters["Source"].ToString();
           srcLoc = srcLoc.Substring(0, srcLoc.IndexOf("/", 8));
           libLoc = srcLoc + e.InputParameters["XmlLocation"].ToString();
     }

    FileSubmitConnection SubmitConnection = (FileSubmitConnection)this.DataConnections["Mainsubmit"];
    SubmitConnection.FolderUrl = libLoc.Substring(0, libLoc.LastIndexOf("/"));
    SubmitConnection.Execute();

    "Mainsubmit" is the data connection name. If there is a spelling mistake in this name, you will get the error. If there is a spelling mistake in the URL used in this connection, again there will be an error. You need to be extra careful when publishing the form. It is hard to notice the problem because the form publishes OK with out any problems and you only get the error when you run the form from SharePoint.

  • Working with Business Data Column

    Working with Business Data Column

    Level: Beginners

    Business Data field type is a new type that enables users to add data from business applications registered in the Business Data Catalog to SharePoint lists and libraries. In the last two articles we saw how to create definition files using Business Data Catalog Definition Editor tool and how to import that definition file into SharePoint. Now we will see how one can make use of the BDC data in a SharePoint list. Following MSDN article has the details on how to add a Business Data column to a list:

    How To: Add a Business Data Column To a List

    Adding a Business Data column to a list is a straight forward process but the definition file created by the Definition Editor tool has to be modified before it could be used in SharePoint. If you use the definition file generated by default by the Definition Editor and try to use the Business Data column, all you get is an error message. This is what you see when you try to access data in a Business Data column:

    Figure 1: Without a filter, BDC data can not be accessed

    Using Business Data Catalog Definition Editor

    Importing BDC Data into SharePoint

    For this demo, I used a small SQL database. This database has only one table with the following fields:

    Database: MusicStore

    Table: Artist

    Fields:

    1. id [int] Not Null
    2. Artist [varchar] (50) Not Null, Primary Key
    3. Album [varchar] (50) Null
    4. RecordingLabel [varchar] (50) Null
    5. NumOfSongs [int] Null
    6. DateReleased [datetime] Null

    You can download the table creation script from here.

    1. You can select a specific record to be shown when adding the Business Data column. By default, all records are shown to the user, user can select one of them to be displayed in the Business Data column. You can also define a filter to filter the records before selecting any one record. I would like to show you how a filter can be added to the application. Filter is useful if your table contains lots of records and it becomes easier to select a record from the filtered set of data. To add a filter, open the definition file in Business Data Catalog Definition Editor by importing it into the Editor. There will be two methods in the file created by default. One will be Find_Artist (where Artist is the table name and the method names in your file will be according to the table names imported from your database) and the other will be FindAll_Artist. Underneath the method name, Right-click "Filters" and select "Add Filter". Give a reasonable name to the filter.

    Figure 2: Add a filter

    2. Remove "FindAll_Artist" method.

    3. Add a new instance and name it "Find_Artists_Instance". Change "MethodInstanceType" to "Finder". This method is required. Web Part will not display filter unless this method is added to the definition. The other instance has "SpecificFinder" type.

    Figure 3: Add a new method instance

    4. Execute the "Find_Artists_Instance". Provide a value in the filter box and click the "Execute" button. You should see the result against the value entered in the filter box.

    Figure 4: Add a filter value and test the method instance

    5. We still need to make some changes in the definition file before it can be used in the SharePoint. Export the definition file and open it in XML editor.

    6. Add following lines after the <Entity> tag:

     <Properties>

    <Property Name="Artist" Type="System.String">Artist</Property>

    </Properties>

    7. Locate the <FilterDescriptor> tag and add following lines between the <FilterDescriptor>  and </FilterDescriptor> tags:

     <Properties>

    <Property Name="UsedForDisambiguation" Type="System.Boolean">true</Property>

    </Properties>

    8. Locate the following lines in the file:

    <Parameter Direction="In" Name="@Artist">
    <TypeDescriptor TypeName="System.System, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IdentifierName="Artist" Name="Artist" />

    This is the input parameter definition. Change the closing tag "/>" to ">" and then add following lines after it:

     <DefaultValues>

    <DefaultValue MethodInstanceName="Find_Artist_Instance" Type="System.String">%</DefaultValue>
    <DefaultValue MethodInstanceName="Find_Artists_Instance" Type="System.String">%</DefaultValue>

    </DefaultValues>

    </TypeDescriptor>

    So, the final input parameter definition will look like the following:

    <Parameter Direction="In" Name="@Artist">
    <TypeDescriptor TypeName="System.String" IdentifierName="Artist" AssociatedFilter="Artist" Name="Artist" >

    <DefaultValues>

    <DefaultValue MethodInstanceName="Find_Artist_Instance" Type="System.String">%</DefaultValue>
    <DefaultValue MethodInstanceName="Find_Artists_Instance" Type="System.String">%</DefaultValue>

    </DefaultValues>
    </TypeDescriptor>
    </Parameter>

    You will notice some more changes in the file but that are not required. For example, you can add following lines to each fields' typedescriptor definition:

    <LocalizedDisplayNames>

    <LocalizedDisplayName LCID="1033">Your field name here</LocalizedDisplayName>

    </LocalizedDisplayNames>

    <Properties>

    <Property Name="DisplayByDefault" Type="System.Boolean">true</Property>

    </Properties>

    That's it. Now the next step is to import the definition file into SharePoint and use the data in the Business Data column. Click here to view the completed definition file. You can also download the completed definition file from here.

    To see how to import the definition file into SharePoint, read this article. After importing the file into SharePoint, follow the steps listed below to add a Business Data column in a library.

    1. Go to the SharePoint library where you would like to add the Business Data column.

    2. Select "Create Column" from the "Settings" menu.

    Figure 5: Create a new column

    3. Enter a name for the column in the "Column name" and select "Business data" as the column type.

    4. Click the browse button.

    Figure 6: Browse the business data applications

    5. Select the BDC application from the list. If there are more than one applications on your server, the list will display all of them. Select your file and click Ok.

    Figure 7: Select a business application

    6. Select the field to be displayed from the drop down that contains all the fields from the BDC. Click OK to add the field.

    Figure 8: Select the field to be shown in the column

    7. If there is no record in the library, add a new record. If it's a document library, the Word application will allow you to select a value in the Business Data column (shown in the Information panel). If there is already a record available in the library, edit its properties.

    Figure 9: Edit document properties

    8. Click the browse button. Enter a valid value in the filter box and click Find. Select the record returned and click OK. Click Ok again to go back to the library.

    Figure 10: Show filtered data

    9. Select "View Profile" from the Business Data column. The profile page will show you the complete details of the record.

    Figure 11: See complete data on the profile page

    As I also mentioned in my previous article, BDC Meta Man is a lot easier to use and it generates a "ready to use" definition file. You don't have to make any manual changes yourself. If you are an absolute beginner, I would suggest take a look at the BDC Meta Man first. The biggest advantage of Microsoft Business Data Catalog Definition Editor tool is that it's free and it has all the features required to generate a definition file that can be tweaked and used by the developers. Beginners will have some difficulty in acquiring the art of "definition file generation" using this tool.  

  • Importing BDC Data into SharePoint

    Importing BDC Data into SharePoint

    Level: Beginner 

    As compared to the first part, this article is short and contains information on how to import the definition file into the SharePoint.

    1. Go to SharePoint Central Administration and open SSP defined for the site where you want to display BDC data.



    Figure 1: Select SSP in SharePoint Central Administration

    2. Click "Import application definition" (Business Data Catalog section).

    3. Click "Browse" and select the definition file. Click "Import" button. Do not change other options on this page. File Type should be "Model".

    4. Now go to your SharePoint site. Select "Edit Page" from "Site Actions".

    5. Click "Add a Web Part"  in the zone of your choice.

    6. Select "Business Data List" web part from the list of available web parts. If this web part is not available, then you will have to add it first to the list. Select "Site Settings" from "Site Actions". Go to Top level site settings if this is not your top level site.  Select "Web parts" from "Galleries" section. Click "New". Select "BusinessDataListWebPart" (See File Name column in the list) and click "Populate Gallery". Now go back to the site. Select "Edit Page" from "Site Actions". Click "Add a Web Part" in the zone of your choice.

    7. Select "Business Data List" from the list of web parts and click "Add".



    Figure 2: Add Business Data List Web Part

    8. The web part would have been added. Click the "Open the tool pane" link in the web part.



    Figure 3: Select Business Data Type

    9. Click the browse button and select the BDC Type. Click "Ok".

    10. The BDC web part will display the data retrieved from the database. See following figure to see how the data looks like.



    Figure 4: BDC data in web part

    We did not define the filter in the definition otherwise you can use the filter option to see specific records. Still you have an option to filter the records using the SharePoint filtering. To apply filtering to the view, do the following:

    11. Modify the web part settings (Select "Modify Shared Web Part" from the web part menu).

    12. Click "Edit View" inside the web part.

    13. You can define a filter in the "Filter" section. For example, you can define a filter with following options:

    Filter: Show items that meet these criteria

    Column: ID

    Condition: is equal to

    Value: Enter value that exists in the database

    This will filter the records. You can define more than 1 filter to display more than 1 record in the web part. Click the "Add" link in the "Filter" section to add more filters. I will try to cover the "Filters in the definition file" in the next article.

  • Using Business Data Catalog Definition Editor

    Using Business Data Catalog Definition Editor

    Category: SharePoint

    Level: Beginner

    Business Data Catalog is a Microsoft Office SharePoint Server feature that allows users to access external data from within SharePoint. SharePoint, as we know, is an excellent collaboration portal that can be used to create robust collaboration applications using Office products. Good thing about the new SharePoint portal is that it also allows you to create applications that involve non-MS products and allows you to create these applications as easily as one would create applications involving MS products. With BDC (Business Data Catalog) users can access data from applications like SAP, Oracle, MySQL, etc with ease. People who have been using SharePoint Server 2007 may also have worked with BDC before. BDC is not new but Business Data Catalog Definition Editor tool is a new edition. If you are entirely new and have never heard about the BDC before, then go through the following article, it will give you an overview of what BDC is and what it does.

    Business Data Catalog Overview

    In this article, I will show you how you can use the new Business Data Catalog Definition Editor to create definition files that are required to connect SharePoint with external applications, also known as Line Of Business (LOB) applications. BDC definition editor tool is available in the latest SharePoint SDK that you can download from the following location:

    Download SharePoint SDK

    After installing the SDK on your machine, you can install the BDC tool by running the setup.exe from the following location:

     LocalDrive:\Program Files\2007 Office System Developer Resources\Tools\BDC Definition Editor

    Once installed, you can use the tool to create the definition files. This tool allows you to use the following connection types:

    1. SqlServer
    2. Oracle
    3. Oledb
    4. Odbc

    Because this is an introductory level article, we will use an Access database to create a definition file and using that file, we will display Access data in a SharePoint list (This will be demonstrated in the second part of this article). By the way, working with Access database is more tricky than working with the SQL database. Importing an SQL database table in to the Business Data Catalog Definition Editor is easy and straight forward but importing a table from an Access database requires some extra steps.

    1. Create a DSN for your Access database. Go to Start > All Programs > Administrative Tools and select "Data Sources (ODBC)".

    Figure 1: Add DSN

    2. Select "System DSN" tab and click "Add" button.

    Figure 2: Select Access driver from the list

    3. Select "Microsoft Access Driver [*.mdb]" from the list of drivers. Remember, this is the driver for the Access 2003 database. If you want to connect to a Access 2007 database, then select "Microsoft Access Driver [*.mdb, *.accdb]" from the list. Click "Finish".

    4. Enter "Data Source Name" and "Description" and click "Select" to select the database. Select your database and click "OK".

    5. Now your DSN is ready.  Open "Microsoft Business Data Catalog Definition Editor" from the Programs Menu.

    Figure 3: Microsoft Business Data Catalog Definition Editor

    6. Click "Add LOB System".

    7. Click "Connect to Database".

    8. Select "Odbc" from the "Connection Type" drop down.

    Figure 4: Select a connection type

    9. In the "Connection String" box, write "DSN=YourDSNname" and click "Connect".

    10. Click "Add Table" button from the right side bar.

    11. All the tables in your database will be displayed. Select the table from which you want to get the data. Drag and drop that table into the main design area.

    Figure 5: Add Table

    12. Click "OK". Enter a name for the LOB System and click "OK".

    BDC Definition Editor will create an LOB System for you. If there was no primary key defined in the table that you used, then the editor will generate an LOB system but that will be of no use to you because the method required to get data from the database will not be created and you will have to create it manually but then what's the point in using the Definition Editor tool if you'd to create the method yourself. Definition file is nothing but an XML file that you can also create manually using any editor including Notepad. This is a complicated file and takes time to create if created manually. The Definition Editor tool gives you an advantage that you can execute the method and check if everything is working OK before you export the settings to an XML file. So to save the time and the effort, I would suggest that you create a primary key in the table but I know, in real world situation, that might not be possible for you to do as you might be working on a client's application. Of course, changing the client's database without his permission could  be a problem or he may not allow you to do so. In that case, you will be left with two options. Either to edit the definition file manually and add the required settings or continue using the Definition Editor tool to add the missing methods. Well, let's complete this example first and then I will show you how to add the missing methods using the Definition Editor tool. For now, I am assuming that your table contained the primary key.

    Some people argue that BDC Meta Man is a much better tool than the Microsoft Business Data Catalog Definition Editor and I am one of those people. Microsoft's tool is new and has issues. Right now, BDC Meta Man offers some advantages over the Microsoft tool and one of those advantages is that it adds the required methods even if there is no primary key in the table unlike the Microsoft tool that does not give you any warning or error but also does not add the methods that are required in the LOB System instance. "SpecificFinder" method is a method that is required for several reasons. One of the reasons is it is required if you want to use a field from the BDC as a "Business Data" column in your SharePoint library. Without the primary key in the table, this method is also skipped alongwith the other methods. BDC Meta Man allows you to add this method even if there is no primary key. It asks the users if they want to select the identifiers and it then shows them the fields to select an identifier from. This is a great feature.

    Figure 6: LOB System - Parameters and Methods

    Definition Editor will generate two methods for you. One method will return records against a value entered in the input parameter. If you look at the Figure 6 above, you will see a method "Find_Table1" where "Table1" is the name of the table. This method has two types of parameters. @ID is the input parameter and  @Table1 is the output parameter. This output  parameter consists of a "DataRecord" (Type: System.Data.IDataReader). Editor will also generate an instance that you can run and test the output. There will be another method created by the Editor, Figure 6 also shows "FindAll_Table1" method. This method returns all the records and does not take an input parameter. A separate instance is created for this method. Go ahead and test any of the instances created by the Editor. For example, let's test the "Find_Table1_Instance". Right click the instance name and select "Execute". This will open a new interface, you will be required to enter a value for the identifier "ID". Enter a value that you know exists in the database and click the "Execute" button. If that ID existed in the database, a relevant record will be returned. Go ahead and click the "Execute" button. What happened? Did it return the record? No? Instead you get an error message. See Figure 7 below.

    Figure 7: Error connecting to Access Database

    The error is: "The  LobSystemInstance Property 'AuthenticationMode' has a value that requires 'Trusted_Connection' in the connection string"

    This is because the application fails to connect with the Access database. It seems to be a bug in the Definition Editor. The solution is that one has to edit the definition file manually and make some changes. We can make those changes through the UI too but UI does not retain the changes so we have to manually edit the definition file.  So first thing you got to do is export the settings to a definition file. Click the main node (LOB System) in the tree and then click "Export" from the menu. Provide a name for the definition file and save it. Open the saved file in any XML compliant editor. You can even open it in Notepad. Locate the following line:

    <Property Name="rdbconnection Dsn" Type="System.String">YOUR DSN NAME WILL BE HERE</Property>

    Figure 8: Change the DSN property

    Replace this line with the following line:

    <Property Name="rdbconnection data source" Type="System.String">"Driver={Microsoft Access Driver
    (*.mdb)};DSN=YOUR DSN NAME WILL BE HERE;Uid=;Pwd=;Trusted_Connection=True;"</Property>

    Save the file and go back to the Definition Editor tool. Don't forget to change the DSN name before saving the file. Click "Import" to import the definition file back in the tool. Now, select the method instance and select "Execute" from the context menu. Enter an ID and click the "Execute" button. You will get the result this time. You can also test the other method, the one that does not take any input parameters, and see if it returned all the records.

    The next step is to import the definition file in the SharePoint. That will be the next article. It will show you how to import the definition file into the SharePoint and how to display the BDC data in a SharePoint list.

    Read Next Article: Importing BDC Data into SharePoint

  • Few Issues with Microsoft Business Data Catalog Definition Editor

    Microsoft Business Data Catalog Definition Editor is a great tool that has made creating application definition file very easy. This tool is available in the latest SharePoint Server 2007 SDK. After installing the SDK, you can install this tool by running setup.exe from the following folder on your server:

    LocalDrive:\Program Files\2007 Office System Developer Resources\Tools\BDC Definition Editor

    I notice there are some issues with this first release of the tool. Of course, it works fine with the SQL server but if you try other DBs, especially through the use of DSNs, it breaks. Following are two instances when it broke while I was trying to add a new LOB system.

    Example 1:

    1. Click "Add LOB System".
    2. Click "Connect to Database"
    3. Select "Oledb" from the connection type
    4. Add following connection string:

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\Administrator\My Documents\Contacts.accdb;Persist Security Info=False;

    5. Click "Connect"
    6. Click "Add Table" and select (drag and drop) a table from the list of available tables.
    7. Click OK and it will give you an error. Click the debug button and select the debugger of your choice. I selected Visual Studio and it gave me the following error message:

    Figure 1: KeyNotFoundException: The given key was not present in the dictionary

    Example 2:

    1. Create a new DSN using "Microsoft Text Driver (*.txt;*.csv)". While creating the DSN, select a directory that contains the .txt or .csv files.
    2. Open BDC Definition Editor tool and click "Add LOB System".
    3. Click "Connect to Database"
    4. Select "ODBC" from the connection type
    5. In the connection string box, add the name of the DSN that you created. For example, dsn=dsnText where "dsnText" is the name of the DSN.
    6. Click "Connect"
    7. Click "Add Table". You will be shown list of files. Select a file without any spaces in the name. Things work without any problem. Now select a file that has spaces in its name and try to add it to the main area. You will get an error:

    "Could not process table "filename".Make sure you have select rights on the Table/View".

    Click OK and an empty table will be added. Try to delete this empty table and you will get another error. See screenshot of the error below:

    Figure 2: Object reference not set to an instance of an object

    These are some minor issues that I am sure will be resolved in future releases. Overall , it's an excellent tool.

    -SSA

  • WS-FileConvertor 1.0c - Convert images to text and upload into SharePoint

    Version 1

    Version 2

    I have made some changes in the previous version and now users can also upload the original files along with the converted text files into the SharePoint.

    FileConvertor version 3

    Click here to download this tool.

    For your convenience, you can create two different views in SharePoint library to show image and text files separately. For example, if the source image files are of GIF type, then you can create a view with the following filter settings:

    Show only items when the following is true:

    Column Name: Name

    Condition: Contains

    Text: gif

    You can make this view the default view and it will only show the image files. Similarly, create another view that will only show the text files. 

    What to expect next? Capability to extract metadata from the converted text files and uploading the original image files along with the extracted meta data. This will allow users to upload only the image files without the need to upload the text files. The common words extracted from the converted text files will be uploaded as metadata. This will allow user