Integrating Office Outlook 2007 and PeopleSoft Using Visual Studio Tools for Office (3.0)

Summary: Learn to use the 2007 Microsoft Office System to extend the Office client and integrate PeopleSoft business data into the context of an information worker’s everyday experience.

Steve Fox, Microsoft Corporation

February 2008

**Applies to:   **2007 Microsoft Office System,Microsoft Office Outlook 2007, PeopleSoft, Microsoft Visual Studio 2008, Microsoft Visual Studio Tools for the Microsoft Office System (3.0)

Contents

  • Overview

  • Office Business Applications

  • Web Services & Component Interfaces

  • Outlook Client Customization

  • Conclusion

  • Additional Resources

Overview

Office Business Applications integrates the 2007 Microsoft Office system with line-of business systems such as PeopleSoft. This integration unlocks key business data and exposes it to information workers who need it the most, thus improving key business decisions and increasing worker productivity.

This article discusses how to take advantage of the 2007 Office system to extend the Office client and integrate PeopleSoft business data into the context of an information worker’s everyday experience using tools such as Visual Studio Tools for Office 3.0 and Microsoft Office SharePoint Server 2007. It also introduces you to the OBA Sample Application Kit for PeopleSoft, a toolkit designed to help you get started integrating PeopleSoft with the 2007 Office system.

Office Business Applications

Office Business Applications use the tools, servers, and services of the 2007 Office system within a service-oriented architecture. At a high level, Office Business Applications are composed of four elements:

  • Line-of business systems

  • Client-side customizations

  • Server-side components

  • Integration services

Office Business Applications bridge the gap between critical business data residing in the LOB systems and the information worker. In many cases, business data is locked away in LOB systems so it is generally unavailable real-time by information workers. Through building Office Business Applications, organizations can unlock that business data and bring the data into the everyday context of the information worker's environment. For example, Office Business Applications can give sales managers direct read/write access to sales forecast data from Office Excel 2007 that is integrated with the LOB system through a Web service.

Web Services & Component Interfaces

Within a service-oriented architecture solution, services are an important component. The W3C defines service-oriented architecture as "a set of components which can be invoked and whose interface descriptions can be discovered and published" (http://www.w3.org/TR/ws-gloss/). Although this is a broad definition, I think there are a couple of key things to underscore when we are talking about solution for service-oriented architecture. You should abstract the services from customization of the Microsoft Office or SharePoint products and technologies. This allows the services (that will be consumed by both the client and the server) to be consumed by whatever business logic is calling them—thus making them platform independent. Further, services should act in isolation of one another. This makes them more resilient to updating and it makes your solutions more scalable. There are other, more complex issues to consider that are outside the scope of this article, such as security and protocol considerations.

With Office Business Applications, you can create services that can be consumed through multiple interfaces. For example, by using Visual Studio Tools for the Office system (3.0) you can create an Office Outlook 2007 add-in and add a reference for a Web service. You can also use other methods to add references to Web services and then consume them from within an Office Business Application. For example, you can integrate Web services with Office SharePoint Server 2007 by using the Business Data Catalog.

We created a simple custom component interface that invokes a Get method that retrieves seven recruiter alerts. Recruiter alerts represent action item alerts for a fictitious recruiter. Figure 1 illustrates a view of data that is served by the component interface from within PeopleSoft. What this interface does is retrieve any work items or alerts for a fictitious recruiter. In this scenario, the recruiter has one interview evaluation and three hires to prepare. It also illustrates the Prepare for Hire action details.

Figure 1. Recruiter alerts component interface

Recruiter alerts component interface

After you create your own component interface or decide which one to consume from within PeopleSoft, you create a Web service that exposes the actions defined within the component interface.

The first step in creating the Web service is to grant full access to the component interface.

To grant full access to the component interface

  1. Log into PeopleSoft and navigate to PeopleTools, Security, Permissions & Roles, and Permission Lists.

    Note that you need to know the specific Permission List (you can add a new one or use an existing one). For our component interface, we used the HCSPCMPINT permission list.

  2. To add your component interface, navigate to the Component Interface Folder tab and then click Add.

  3. Enter the name of your component interface in the Component Interface Name field. For example, our component interface is called CI_HRS_MSFT_ALERTS.

  4. Click Edit, click Full Access, and then click OK.

    Figure 2: Setting permissions on component interface

    Setting permissions

  5. Click Save.

At this point, you are ready to set up your Web service.

To set up the Web service

  1. Navigate to PeopleTools, Integration Broker, Web Services, and CI Based Services.

    Enter the required information about your component interface (i.e. the Component Interface Name and the Component Name). In our case, the component interface name is CI_HRS_MSFT_ALERTS, and the component name is HRS_MSFT_ALERTS.

  2. Check the Select checkbox beside CI_MSFT_ALERTS, and then click Review CI Status.

    A new page appears and you will see that the Get Method for CI_ HRS_MSFT_ALERTS should not be created yet.

  3. Click the checkbox beside CI_ HRS_MSFT_ALERTS and then click Display Select Action.

  4. TO take you back to the previous page and show you that the operation was created, click Perform Select Actions.

  5. Click View Service Definition, and then click the Provide Web Service.

  6. Select the checkbox beside the CI_CI_MSFT_ALERTS service.

  7. Click Next, and then click View WSDL.

  8. To complete the steps, click Return, then click Next and click Finish. PeopleSoft will show you the WSDL URL. In our case, the resulting WSDL was: http://moss.litwareinc.com:8000/PSIGW/PeopleSoftServiceListeningConnector/CI\_CI\_HRS\_MSFT\_ALERTS.1.wsdl. Figure 3 shows the service we created along with the one method within that service—the Get method. We’ll use this again later as we set up the Web service within Visual Studio.

    Figure 3. Component interface Web service

    Component interface Web service

The last step is to grant full access to the Web service.

To grant full access to the Web service

  1. Navigate to PeopleTools, Security, Permissions & Roles, and Permission Lists.

  2. Navigate to the appropriate Permissions List (in our case HCSPRS9030) and click the Web Services Page tab. Enter the name of the Web service that corresponds to your component interface (ours was CI_CI_HRS_MSFT_ALERTS).

  3. Click Edit.

  4. Click Full Access, click OK, and then click Save.

After you create a Web service proxy to your component interface, you can now use that service in a client-side customization (or on the server via the Business Data Catalog). Integrating the Web service with the client customization is a relatively straightforward process, which we will discuss next. Specifically, we will discuss how to create a Visual Studio Tools for Office Outlook add-in and then integrate the Web service we just created into the client-side add-in.

Outlook Client Customization

Companies are excited about the ability to customize and extend Office Outlook 2007 as a product. For many, Office Outlook 2007 represents a productivity application that people use day in and day out. Incorporating functionality within Office Outlook 2007 makes more sense than designing, developing and supporting another tool. The ability to use existing Office applications and environments is why Office Business Application development is picking up significant momentum. You can extend core applications like Office Outlook 2007 and incorporate LOB system integration directly within the context of the information worker's everyday work environment. The business gains, such as engineering cost gains, productivity gains, decision-making gains, are significant. Applying this to PeopleSoft takes on a new meaning because you now unlock business data and give information workers access to the information that they need

To create this client-side component of an Office Business Application is straightforward provided Visual Studio Tools for Office and Office Outlook 2007 are installed. To create this component, you will open Visual Studio 2008 and create a new Visual Studio Tools for Office Outlook add-in project and then use this project as the basis for your client-side customization.

To create a new project

  1. Open Visual Studio 2008.

  2. Cick File, then click New, and then click Project.

    This invokes the New Project dialog where you can click either Visual Basic or C# and then click the Office node.

    Within the Office node (where the Visual Studio Tools for Office project templates live), you can see child nodes 2007 and 2003. The list area corresponding to the Office node contains project templates for both Office 2007 and 2003.

  3. Complete the other project properties and click OK to create your project.

    In Figure 4, you can see the Office Outlook 2007 add-in project template and the project called PSFTSample.

    Figure 4. New project dialog

    New project dialog

You can link the Web service to a custom object within the project to create the client-side component within the shell of the add-in project you created, for example custom button that triggers the remote call using the Web serviceNext, you can create a custom task pane within Office Outlook 2007 that makes a call to the service proxy. In addition, you can layer a Windows Presentation Foundation (WPF) control on top of the custom task pane. Windows Presentation Foundation is a more sophisticated graphics display technology allowing you to separate your design and development experiences. It is growing in use and popularity because of its ability to abstract the UI design process away from the development process and for the more sophisticated UI design you can build into your solutions. The custom task pane is just one way of extending Office Outlook 2007; you can also create custom Office Outlook 2007 form regions, customize the Office Outlook 2007 ribbon or command toolbar, or embed forms and dialogs to handle many different types of events and services.

After you create the new project, you need to do three things.

  • Create the user control. Since we are using a Windows Presentation Foundation user control, we first need to create a standard Windows Forms user control and then host the WPF control on the Windows Forms user control.

  • Create the WPF control.

  • Create an instance of the custom task pane that hosts the WPF user control. Note that you can eliminate the WPF user control if you want to just stick with traditional Windows Forms controls.

To create the user control

  1. Right-click your project, click Add, and then click New Item.

  2. In the Add New Item dialog, select User Control – see Figure 5.

  3. Give your user control a name and click Add, which adds the user control and all the default code to the project.

    Figure 5. Add new item dialog

    Add new item dialog

Next, add the Windows Presentation Foundation user control that is hosted by the Windows Forms user control you just added. To add the WPF user control, create a WPF User Control Library which by default contains a WPF User control.

To create the WPF user control

  1. Click File, Add, New Project, Windows, and then select WPF User Control Library.

  2. Provide a name for your control and click Add.

    This adds the WPF user control and default code to your new project. Two files, a .xaml and .xaml.cs, are added to the newly added WPF user control project node.

    You can use these files to define what the user interface (UI) looks like through defining the XAML in the XAML Designer. You can also use them to define events that are mapped to the elements within the XAML file. Figure 6 illustrates the XAML Designer view in the Visual Studio 2008 IDE.

    Figure 6. Adding WPF user control to project

    Adding WPF user control

To create your UI, you can, similar to the Windows Forms experience, drag and drop controls from the Toolbox onto the WPF Designer surface. After doing this, you can add the default events for a given control type to the controls by double-clicking the controls that ads the events in the code-behind file (that is the xaml.cs file). You can also edit the properties of the controls in the Properties window, or you can hand-edit the XAML—a XML-based language that has the ability to add specific metadata about a particular control. For example, Listing 1 illustrates the XAML added to my project, which defines a number of objects like textboxes, labels, and buttons. Notice that the very first line of XAML code refers to the C# file that corresponds to this XAML file—where all classes or events that map to the XAML file live. Specifically, it refers to UserControl1, the default name for the user control.

<UserControl x:Class="WpfControlLibrary.UserControl1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="332" Width="300">
    <Grid Height="330">
        <TextBox Height="21" Margin="55,19,0,0" Name="textBoxOperatorID" VerticalAlignment="Top" HorizontalAlignment="Left" Width="53">HPY</TextBox>
        <Label Height="24" Margin="12,17,0,0" Name="labelOperatorID" VerticalAlignment="Top" HorizontalAlignment="Left" Width="46">OPRID:</Label>
        <Button Height="23" Margin="112,17,0,0" Name="buttonDisplay" VerticalAlignment="Top" Click="buttonDisplay_Click" HorizontalAlignment="Left" Width="56">Display</Button>
        <Rectangle Margin="12,52,9,38" Name="rectangleContent" Stroke="Black" />
        <Label Height="23" Margin="22,66,0,0" Name="labelAutoMatchResults" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120">Auto Match Results:</Label>
        <TextBox Margin="142,66,0,0" Name="textBoxAutoMatchResults" Height="21" VerticalAlignment="Top" HorizontalAlignment="Left" Width="42" />
        <Label Height="23" HorizontalAlignment="Left" Margin="22,94,0,0" Name="labelPostJobOpenings" VerticalAlignment="Top" Width="120">Post Job Openings:</Label>
        <TextBox Height="21" Margin="142,94,0,0" Name="textBoxPostJobOpenings" VerticalAlignment="Top" HorizontalAlignment="Left" Width="42" />
        <Label Height="23" HorizontalAlignment="Left" Margin="22,121,0,0" Name="labelInterviewsToday" VerticalAlignment="Top" Width="120">Interviews Today:</Label>
        <TextBox Height="21" Margin="142,121,0,0" Name="textBoxInterviewsToday" VerticalAlignment="Top" HorizontalAlignment="Left" Width="42" />
        <Label HorizontalAlignment="Left" Margin="22,148,0,160" Name="labelInterviewEvaluation" Width="120">Interview Evaluation:</Label>
        <TextBox Margin="142,148,0,0" Name="textBoxInterviewEvaluation" Height="22" VerticalAlignment="Top" HorizontalAlignment="Left" Width="42" />
        <Label Height="23" HorizontalAlignment="Left" Margin="22,0,0,130" Name="labelPrepareJobOffer" VerticalAlignment="Bottom" Width="120">Prepare Job Offer:</Label>
        <TextBox Height="21" Margin="142,177,0,0" Name="textBoxPrepareJobOffer" VerticalAlignment="Top" HorizontalAlignment="Left" Width="42" />
        <Label Height="23" HorizontalAlignment="Left" Margin="22,0,0,102" Name="labelApproveJobOffer" VerticalAlignment="Bottom" Width="120">Approve Job Offer:</Label>
        <TextBox Height="21" Margin="142,205,0,0" Name="textBoxApproveJobOffer" VerticalAlignment="Top" HorizontalAlignment="Left" Width="42" />
        <Label Height="23" HorizontalAlignment="Left" Margin="22,0,0,74" Name="labelApproveJobOpening" VerticalAlignment="Bottom" Width="120">Approve Job Opening:</Label>
        <TextBox Height="21" Margin="142,233,0,0" Name="textBoxApproveJobOpening" VerticalAlignment="Top" HorizontalAlignment="Left" Width="42" />
        <Label Height="23" HorizontalAlignment="Left" Margin="22,0,0,47" Name="labelPrepareForHire" VerticalAlignment="Bottom" Width="120">Prepare For Hire:</Label>
        <TextBox Height="21" Margin="142,260,0,0" Name="textBoxPrepareForHire" VerticalAlignment="Top" HorizontalAlignment="Left" Width="42" />
    </Grid>
</UserControl>

Listing 1: XAML Code

At this point, you created the Web service (wrapped around the PeopleSoft component interface) and the UI separately. Before we create an instance of the custom task pane, we need to first ensure that the Web service and any controls on the WPF user control actually do something. To do this, you first add a reference to the Web service to our solution. Next, implement any members of that service in our code to integrate the service with the UI—thus creating our very simple Office Business Application.

To reference the Web service, right-click the project in Solution Explorer and select Add Service Reference. You can add the URL referencing the WSDL for your Web service after invoking the Add Service Reference dialog (see Figure 7). Next, click Go and Visual Studio will, if the service is accessible, load the services and operations that correspond to the service. As you can see in this service, we only have one service: an HR alert service that retrieves a number of work items to complete (i.e. alerts). This illustrates how you can integrate services with the Visual Studio Tools for Office solution to create your Office Business Application using PeopleSoft as the back-end data source and services as the proxy.

Figure 7. Adding Web service reference

Adding Web serve reference

The last step is to implement the CI_CI_HRS_MSFT_ALERTS_G method by attaching it to our button control in the WPF user control. You can add code to a WPF control directly in the XAML or you can double-click the designer and then add the event handler code there. The code we have hooked up to the button retrieves alerts from PeopleSoft and then maps those alerts to a specific UI control, that is, the textbox controls. Listing 2 provides an overview of this code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using DB = System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Configuration;
using WpfControlLibrary.PSFT.Service;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Security;

namespace WpfControlLibrary
{
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }
        private void buttonDisplay_Click(object sender, RoutedEventArgs e)
        {
            CI_CI_HRS_MSFT_ALERTS_PortTypeClient port = null;
            Get__CompIntfc__CI_HRS_MSFT_ALERTSTypeShape alert = null;
            Get__CompIntfc__CI_HRS_MSFT_ALERTSResponseTypeShape response = null;
            try
            {
                port = new CI_CI_HRS_MSFT_ALERTS_PortTypeClient();
                port.Open();
                alert = new Get__CompIntfc__CI_HRS_MSFT_ALERTSTypeShape();
                alert.OPRID = new OPRIDTypeShape();
                alert.OPRID.Value = textBoxOperatorID.Text;                
                response = port.CI_CI_HRS_MSFT_ALERTS_G(alert);
                textBoxAutoMatchResults.Text = response.AUTO_MATCH.Value;
                textBoxPostJobOpenings.Text = response.JOB_POSTINGS.Value;
                textBoxInterviewsToday.Text = response.INTERVIEWS_TODAY.Value;
                textBoxInterviewEvaluation.Text = response.INTERVIEW_EVALS.Value;
                textBoxPrepareJobOffer.Text = response.PREPARE_OFFERS.Value;
                textBoxApproveJobOffer.Text = response.JOBOPENING_APPROVAL.Value;
                textBoxApproveJobOpening.Text = response.OFFERS_FOR_APPROVAL.Value;
                textBoxPrepareForHire.Text = response.PREP_FOR_HIRE.Value;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (port != null)
                {
                    port.Close();
                }
            }
        }
    }
}

Listing 2: WPF User Control Code Behind

Now that we have a regular user control and a WPF user control with some working code in it, the next step is to add the WPF control to the user control. To do this, you must first build your project after which the WPF user control is added to your Toolbox. You can then, similar to the other controls in the Toolbox, drag and drop the controls to the Windows Forms user control surface. You should end up with something similar to Figure 8.

Figure 8. Visual Studio WPF user control

Visual Studio WPF user control

The last step in creating the UI portion of the Office Business Application is to create a custom task pane that hosts the Windows Forms user control and the WPF user control library. Note that this is just one way of hosting the controls. You can also use the custom Outlook 2007 Form Region to host the controls and call the Web service. See the Further Reading section for more information.

You can invoke the custom task pane either through an explicit event handler such as a ribbon element, or you can add the necessary code to invoke the custom task pane within the core add-in class (called ThisAddIn.cs). In the core class, you will find a ThisAddIn_Startup and ThisAddIn_Shutdown, which execute code when the Office Outlook 2007 starts or shuts down the add-in. The code to actually create an instance of the custom task pane object is also quite straightforward and is illustrated in Listing 3. Specifically, you can use the CustomTaskPane object and when calling the Add method, pass in an instance of your Windows Forms user control (in this case called OutlookTaskPane) and a string value for the title of the custom task pane (in this case "PSFT").

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools;

namespace PSFTSample
{
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            CustomTaskPane customTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(
                new OutlookTaskPane(),
                "PSFT"
                );
            customTaskPane.Visible = true;
        }
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }
    }
}

Listing 3: Core VSTO Add-In Class

Note that we do not have any code in the Shutdown method; however, you can use this event to add any clean-up code to your solution.

At this point, if you decided to work along with this article, you have created your first, albeit simple, Office Business Application. So, what now? The next section of this article discusses the forthcoming OBA Sample Application Kit for PeopleSoft. This kit uses some of the code mentioned in the article, but provides much more detailed guidance.

OBA Sample Application Kit for PeopleSoft

The OBA Sample Application Kit for PeopleSoft is guidance for developers who want to start building Office Business Applications using PeopleSoft as the back-end LOB system. You can apply many of the principles (and to a certain degree the code) in the kit to other Office Business Applications, but this kit is specifically geared towards Office Outlook 2007 integration with PeopleSoft.

The OBA Sample Application Kit for PeopleSoft is one in a series of kits (other kits deal specifically with SAP and Siebel) and provides a number of key deliverables for the developer: a) source code, b) whitepaper, c) MSI, and d) an installation guide. For those developers who are trying to learn more about Office Business Applications and specifically trying to learn about how to integrate PeopleSoft with the Office system, this kit represents a great way to get started.

The OBA Sample Application Kit for PeopleSoft covers key areas in Office Business Application development. Specifically, it provides guidance to create Web services around component interfaces within PeopleSoft. So, much like you saw in this article, the kit goes into greater detail and provides proscriptive guidance for the developer. It also illustrates how you can customize the Office client using Visual Studio Tools for Office 3.0, the latest Office development technology that ships with Visual Studio 2008 Professional (and above). And it also shows you how you can integrate services and SharePoint Server 2007 using the Business Data Catalog. Look for the OBA Sample Application Kit for PeopleSoft to be released to MSDN in late March, 2008.

Conclusion

In this article, you learned what an Office Business Application is and I walked you through how you to create a very simple one. This article also showed you how to use the 2007 Office System to extend the Office client and integrate PeopleSoft business data into the context of an information worker’s everyday experience through Visual Studio Tools for Office 3.0, a component technology in Visual Studio 2008. You can do many exciting things with Visual Studio Tools for Office 3.0, such as create add-ins for Word, Excel, PowerPoint, and a multitude of other Office applications.

While this article specifically discussed PeopleSoft Web services, you can apply the same concepts of Web service integration using other LOB systems. That is, in many cases you will design your Web services first before integrating them with either the client or server, and many LOB systems come with their own native tools that you can use to create Web services, for example SAP.

Additional Resources

Office Business Application examples

Office Developer Center

Visual Studio Tools for Office Forum

Visit the Visual Studio Tools for Office Developer Center

SharePoint Developer Center

Six Microsoft Office Business Applications for Office SharePoint Server 2007 (MS Press)