Show TOC

Upgrading Older Outlook ItemsLocate this document in the navigation structure

Context

Already existing Outlook items, which are still based on an older version of the OData service, can be upgraded by invoking a silent query operation of the SAP Gateway service. On starting Microsoft Outlook, older items can be upgraded to latest OData service version by:

  • Invoking a silent query operation of the SAP Gateway service
  • Outlook Search – Find all the Outlook items and manually trigger the query operation from Microsoft Outlook.

Invoking Silent Query Operation on Outlook Start

Context

On starting the Microsoft Outlook application, this method checks the version of Microsoft Outlook add-in (in the registry). Depending on the registry value (it checks whether the new version of the service is available or not), a query operation of the OData service is triggered. The query operation fetches all the items and does the required changes to the existing Microsoft Outlook items.
Note Invoking query via code is the recommended method for achieving an upgrade.

Procedure

  1. Open the project in Visual Studio and navigate to the Solution Explorer.
  2. Expand Start of the navigation path Project folder (TimeRecording) Next navigation step Microsoft Outlook  Next navigation step ThisAddIn.cs  End of the navigation path. Upgrade_invoke
  3. Locate the method CheckForUpgrade in the ThisAddIn.cs, and adjust the code according to the in-line comments.
  4. Uncomment the code inside the CheckForUpgrade method.

This code opens a registry key and stores service version value in registry. If the version in the registry is different from version in App.config file, the Microsoft Outlook items are upgraded, and registry value is updated with the latest version value. If the registry value is not found then it is the first time invocation and registry values are stored. If the version values are the same then the upgrade is not triggered.

  1. Locate the method CreateRegistryEntries() method in the ThisAddIn.cs, and uncomment the code inside it.

This code gets the current version of the Time Management service and stores it in a registry location. Adjust the code according to the in-line comments.

  1. Locate the method UpdateRegistryValue() method in the ThisAddIn.cs and uncomment the code inside it.

This code updates the service version to latest version. Adjust the code according to the in-line comments.

  1. Locate the method UpgradeItems() method in the ThisAddIn.cs and uncomment the code inside it.This code will make sure that the query method is invoked silently. All the older Time Management items will be upgraded silently.

Upgrading Items by Microsoft Outlook Search

Context

This is the second option to upgrade older Microsoft Outlook items and is less the preferred one.
Note The Microsoft Outlook search will try to silently add the newly added property to the Microsoft Outlook items and also remove the obsolete properties from Microsoft Outlook items. But the user still needs to invoke a query operation upon opening the Microsoft Outlook application. Otherwise, the user will get a Save confirmation pop-up for each opened item. In order to avoid this pop up, a manual GET ALL call should be invoked from the Microsoft Outlook ribbon by the user.

Procedure

  1. Do the following to update the UpgradeItems method with the code as specified below:
    1. This code explains how the new OData service property can be added to the Microsoft Outlook calendar item.
      private void UpgradeItems()
              {
                 PerformOutlookSearch();
              }
      
              private void PerformOutlookSearch()
              {
                  // get outlook appointment folder for your Template and get all the SAP timesheet entry items. Change “TimeMgmt” as per your project Template name
                  
                  BusinessApplication application = BusinessApplicationFactory.GetBusinessApplication("TimeMgmt");
                  Folder outlookFolder = null;
      
                  if (application.OutlookFolderName != null)
                  {
                      outlookFolder = OutlookUtilities.GetOutlookFolder(OlDefaultFolders.olFolderCalendar, application.OutlookFolderName);
                  }
                  else
                  {
                      outlookFolder = OutlookUtilities.GetOutlookFolder(OlDefaultFolders.olFolderCalendar);
                  }
      
                  Items olItems = outlookFolder.Items;
      
                  if (olItems.Count > 0)
                  {
                      foreach (AppointmentItem item in olItems)
                      {
                          // for each Appointment Item find out if its a valid SAP item, if yes, add/remove user properties...
                          UserProperties properties = item.UserProperties;
                          if (properties.Find(Constants.SAPITEM) != null)
                          {
                              UserProperty userProperty = properties.Add(OutlookUtilities.GetUserPropertyName("MyRecordID"), OlUserPropertyType.olText, false, 1);
                              //set a dummy value here
                              userProperty.Value = "123";
                              OutlookUtilities.CleanUpResources(userProperty);
                              item.Save();
                          }
                      }
                  }
              }

      The code given above explains how the Microsoft Outlook search is performed on Microsoft Outlook Calendar items. Then for each calendar item, a new property with a dummy value is added. This dummy value will be replaced by the actual value once the query operation is performed from Microsoft Outlook.

    2. This code explains how the OData service property can be removed from the Microsoft Outlook calendar item.
      private void UpgradeItems()
              {
      
                  PerformOutlookSearch();
              }
      
              private void PerformOutlookSearch()
              {
                  // get outlook appointment folder for your Template and get all the SAP timesheet entry items. Change “TimeMgmt” as per your project Template name
                  
                  BusinessApplication application = BusinessApplicationFactory.GetBusinessApplication("TimeMgmt");
                  Folder outlookFolder = null;
      
                  if (application.OutlookFolderName != null)
                  {
                      outlookFolder = OutlookUtilities.GetOutlookFolder(OlDefaultFolders.olFolderCalendar, application.OutlookFolderName);
                  }
                  else
                  {
                      outlookFolder = OutlookUtilities.GetOutlookFolder(OlDefaultFolders.olFolderCalendar);
                  }
      
                  Items olItems = outlookFolder.Items;
      
                  if (olItems.Count > 0)
                  {
                      foreach (AppointmentItem item in olItems)
                      {
                          // for each Appointment Item find out if its a valid SAP item, if yes, add/remove user properties...
                          UserProperties properties = item.UserProperties;
                          if (properties.Find(Constants.SAPITEM) != null)
                          {
                              UserProperty userProperty = properties.Find(OutlookUtilities.GetUserPropertyName("ApprovalDate"));
      						userProperty.Delete();
                              OutlookUtilities.CleanUpResources(userProperty);
                              item.Save();
                          }
                      }
                  }
              }
  2. Build and install the new GWM Outlook Add-in in Microsoft Outlook. See Creating an Installer for a GWM Visual Studio Add-In for more information.
  3. From Outlook, choose the GetAll menu to fetch the required details.
    The newly added property will be mapped with the actual data obtained from the backend and the old properties will be removed from the OData service