In this section, as an example for extending the generated code, we will add a filter to the GetAll function to assist the user to fetch onselect, the recipient when forwarding a task.
The GWM Outlook project generates the GWM Outlook add-in template with classes required for handling connectivity to SAP system to do the following functions:
The table below describes the major classes generated by GWM Outlook Add-in wizard.
Class Name | Description |
---|---|
BusinessConnectivityHelper | This class handles the connectivity to the OData endpoint.
It performs the required handling to enable authentication to the SAP Gateway endpoint. It also initiates the call to the SAP Gateway endpoint with requestId and SAP Passport required for enterprise readiness. |
Logger | This class provides the API to log the necessary information to
the Event Viewer, or local file. The class uses System.Trace API and therefore the logging can be enabled through app.config. SeeLogging in the GWM Generated Application. This class can be extended to support any other custom logging FW (including third party logs). |
<proxyName>SAPExtensions | This is the extension class to the generated proxy which contains OData4SAP semantics information such as, labels, filter values as maintained in the service in the SAP Gateway system. |
<outlookitemtype>InspectorWrapper | This is the wrapper class over the “Outlook” inspector which can be extended to perform specific operation during the launch of the outlook item UI. Example, we can extend the class to display custom task panes. See Custom Task Pane with analytics. |
UserPropertiesTab | This is the Windows Form class which
provides the UI to show the Outlook custom properties, which cannot
be viewed in the standard Outlook UI by default. This class can be extended to show more custom properties, e.g complex properties (for more information refer to part II of this series) |
AssociatedEntitesTab | This is the Windows Form class which
provides the UI to show the associated entities tab. This class can be extended to show more associated entities or even data coming from the different OData endpoint (for more information refer to part III of this series) |
<ApplicationName>BussinessApplication | This class provides the functionality to map the SAP business
entity with the Outlook fields, and provides API to fetch records
from SAP, create, update and delete record from SAP. In some cases, the method implementation may be blank depending on the service. For example, in case the OData service does not support create operation (like in this case), then the create method will be blank. This class can be extended to provide a different mapping, or even to show more information in the task pane. |
<ApplicationName>Validator | This class provides the functionality to validate the data
entered by the user. By default, we perform the validation for mandatory properties (in case the mandatory property is missing, an error is displayed to the user). This can be extended to perform custom validation as well |
This will be implemented by introducing the Country code parameter as a property in the Application Configuration settings. The advantage of maintaining a value in the Application configuration is that it can be changed by the user later, and the new value will be read by the Outlook project without the need to build and deploy the project again.
The Application configuration files contain settings specific to an application. This file contains configuration and settings that the application can read at runtime.
<appSettings> <add key="CountryCode" value="DE" /> </appSettings>
string countryCode = ConfigurationReaderHandler.Instance.GetConfigValue("CountryCode");
When a project is generated, the SAP.IW.GWM.Common dll will be created in the References folder under the Solution Explorer region.
In this DLL, there is a class ConfigurationReaderHandler that contains the method GetConfigValue. This method reads the configuration maintained in the file, App.config at runtime, hence in the above code, we call the method in the ConfigurationReaderHandler class.
//var serviceresponse = serviceContext.BusinessPartnerCollection.Execute() as QueryOperationResponse<GWDEMO.BusinessPartner>; and add the following code snippet QueryOperationResponse<GWDEMO.BusinessPartner> serviceresponse = null; if (string.IsNullOrEmpty(countryCode)) { serviceresponse = serviceContext.BusinessPartnerCollection.Execute() as QueryOperationResponse<GWDEMO.BusinessPartner>; } else { serviceresponse = serviceContext.BusinessPartnerCollection.AddQueryOption("$filter", string.Format("CountryCode eq '{0}'", countryCode)).Execute() as QueryOperationResponse<GWDEMO.BusinessPartner>; }