Show TOC

Removing Properties from SAP Gateway ServiceLocate this document in the navigation structure

This chapter explains how to upgrade your project when the SAP Gateway service has changed and properties have been removed from the service.

Context

The Time Management service will be used as an example to showcase how an upgrade can be achieved. The Add SAP Service Reference function will be utilized to update the proxy classes and the App.config file.

Updating the Proxy classes in the GWM Template and Configuration File

Procedure

  1. Open the time recording project to be upgraded in Microsoft Visual Studio.
  2. Right click on your project, for example, TimeRecording, in the Solution Explorer, and select Add SAP Service Reference.Upgrade_addSAPREF
    The Add SAP Service Reference window appears:
  3. Select Add Service.
    Note The Explore Services option can also be selected.
    The Service Explorer window appears.
  4. Select the updated OData service, Time Management.
  5. Click OK to proceed.
    The proxy classes and app.config file will be updated.

    Now the project has been updated to call the latest version of the sevice, version 3.

    Next step is to remove the property from the project. The properties that were removed might either be from the user properties or from the Outlook properties tabs. Depending upon where this field was present, the code must be removed from the corresponding method.

Removing the Property from the Project

Context

Follow the steps below to remove the fields from the existing Outlook project:

Procedure

  1. Navigate to the Solution Explorer view and expand Start of the navigation path Project (time management) Next navigation step Outlook Next navigation step Appointment Next navigation step TimeMgmt Next navigation step TimeMgmtBusinessApplication.cs End of the navigation path.
    Note The names of the folders depend on the names chosen during generation of the project using the GWM Wizard.
  2. Double click TimeMgmtBusinessApplication.cs to open it.
  3. Navigate to AddUserProperties(AppointmentItem outlookItem) method and remove the code corresponding to ApprovalDate.
    This ensures that the ApprovalDate property is removed from the calendar Outlook entity.Upgrade_TimeMgmtBusinessApplication.cs
  4. Navigate to MapUserPropertiesToEntity method in the TimeMgmtBusinessApplication.cs, and remove the code corresponding to Approval Date. This method maps outgoing Microsoft Outlook user properties to OData service properties. Typically, this method is called during the Create, and Update operations of the OData service.
    Remove these lines.
    			userProperty = userProperties[OutlookUtilities.GetUserPropertyName("ApprovalDate")];
                    if (userProperty != null)
                    {
                                   if (!string.IsNullOrEmpty(userProperty.Value))
                        {                                                                                                                                                                               
                                             entity.ApprovalDate = userProperty.Value;
                                                                                                                                                                                                                        
                                      }                                 
                        OutlookUtilities.CleanUpResources(userProperty);
                    }
    

    ApprovalDate is the name of the removed property in the OData service.

  5. Navigate to the MapStandardFieldsToEntity method in the TimeMgmtBusinessApplication.cs to remove the code corresponding to ApprovalDate, if applicable. This method maps outgoing Microsoft Outlook standard properties to OData service properties. Typically, this method is called during the Create, and Update operations of the OData service.
    Remove these lines, if a mapping for ApprovalDate exits.
    
    //entity.ApprovalDate=outlookItem.<outlookProperty>;
    
    Note: <outlookProperty> is the outlook property to which ApproveDate was mapped before upgrade.

    ApprovalDate is the name of the removed property in the OData service.

  6. Navigate to the MapEntityToStandardFields method in the TimeMgmtBusinessApplication.cs to remove the code corresponding to ApprovalDate. This method maps incoming OData service properties to Microsoft Outlook standard properties. Typically, this method is called during the Read, and Query operations of the OData service
    Remove these lines, if a mapping for ApprovalDate exits.
    
    // outlookItem.<outlookProperty>=entity.ApproveDate;
    
    Note: <outlookProperty> is the outlook property to which ApproveDate was mapped before upgrade.
  7. Navigate to the MapEntityToUserProperties method in the TimeMgmtBusinessApplication.cs, and remove the code corresponding to ApprovalDate. This method maps incoming OData service properties to Microsoft Outlook user properties. Typically, this method is called during the Read, and Query operations of the OData service.
    // userProperty = userProperties[OutlookUtilities.GetUserPropertyName("ApprovalDate")];
            //            if (userProperty == null)
            //            {
            //                  userProperty = userProperties.Add(OutlookUtilities.GetUserPropertyName("ApprovalDate"), OlUserPropertyType.olText, false, 1);
            //           }
            //           if(entity.ApprovalDate!=null)
            //           {
            //                 userProperty.Value = entity.ApprovalDate.ToString();
            //                 
            //           }
            //           else
            //           {
            //                 userProperty.Value =null;
            //           }
            //           OutlookUtilities.CleanUpResources(userProperty);
    

    ApprovalDate is the name of the removed property in the OData service.

  8. Navigate to the method LoadCustomFieldsDataGrid in the UserPropertiesTab.cs file. This method is responsible for adding properties to the data grid, which shows the data on the user properties tab.

    Update the code to remove the unwanted fields from the data grid.

    UpgradeUserProperties

  9. The already existing Outlook items based on version 2 must be updated to version 3. Refer to the steps in Upgrading Older Outlook Items section to upgrade the Outlook items.
  10. Build the updated project and create a new VSTO installer. See Creating an Installer for a GWM Visual Studio Add-In to create a new installer.
  11. Open Microsoft Outlook, try to access the individual Outlook items and verify that fields which were removed from the OData service are no longer present.