Show TOC

Updating a Template After the Service Has Been UpdatedLocate this document in the navigation structure

Context

In this section, we will update a template that calls a Time Management service which has been revised to contain new properties. The 2nd version of the service will contain a newly added property called, MyRecordID. On updating the project, all the exsiting older Outlook appointment items, should contain the newly added user property.

The above scenario is achieved by adding an SAP service reference to the existing service.

Procedure

  1. Open the Outlook template to be updated in Visual Studio. For example, TimeRecording .
  2. Right click the project in the Solution Explorer and select Add SAP Service Reference.Upgrade_addSAPREF
    The Add SAP Service Reference window appears:
  3. Select Add Services.
    Note The Explore Services option can also be selected.
    The SAP Gateway Service Explorer window appears.
  4. Select the updated OData service, for example, Time_Management.
  5. Click OK to proceed.
    The proxy classes and the App.config file will be updated.

Now the service has been updated from version 1 to version 2.

The next step is to add the new properties from the service. The properties to be added might come from the user properties or from the Outlook properties tabs. The code must be modified in the corresponding method, depending on where this field was present.

  1. Navigate to the Solution Explorer view, and expand Start of the navigation path Project (TimeRecording) 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, and the class file may vary depending upon the name given to the template in the GWM wizard.
  2. Double click TimeMgmtBusinessApplication.cs to open it.
  3. Navigate to AddUserProperties(AppointmentItem outlookItem) method, and add the newly added property (the version 2 of the service that has MyRecordID property added). This ensures that the newly added property becomes part of the Microsoft Outlook entity. UpgradeRemovingProperites
    userPropertyName = "MyRecordID";
                    userProperty = userProperties.Add(OutlookUtilities.GetUserPropertyName(userPropertyName), OlUserPropertyType.olText, false, 1);
                    OutlookUtilities.CleanUpResources(userProperty);
     
    

MyRecordID is the name of the newly added property in the OData service.

  1. Navigate to MapEntityToStandardFields method in TimeMgmtBusinessApplication.cs, and add the code corresponding to the property, MyRecordID. 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.
    outlookItem.<outlookProperty>=entity.MyRecordID;
    
    Note: .<outlookProperty> is the outlook property of your choice.
              Ex:  outlookItem.Subject=entity.MyRecordID;
    
    

    MyRecordID is the name of the newly added property in the OData service

  2. Add mapping for the Standard Outlook properties (for read, and query operations):
    • Navigate to MapEntityToUserProperties, method in TimeMgmtBusinessApplication.cs, and add the code corresponding to MyRecordID. 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.
    • MyRecordID is the name of the newly added property in the OData service.
    • If the added OData properties are mapped to the standard Outlook fields, then add the corresponding mapping code inside the following method.
    userProperty = userProperties[OutlookUtilities. GetUserPropertyName ("MyRecordID")];
     if (userProperty == null)
         {
            userProperty = userProperties.Add(OutlookUtilities.GetUserPropertyName("MyRecordID"), OlUserPropertyType.olText, false, 1);
         }
         if (entity.MyRecordID != null)
          {
             userProperty.Value = entity.MyRecordID.ToString();
          }
         else
          {
             userProperty.Value = null;
          }
        OutlookUtilities.CleanUpResources(userProperty);
  3. Add mapping for Standard Outlook properties (for create, and update operations):
    • Navigate to MapStandardFieldsToEntity method in TimeMgmtBusinessApplication.cs, and add the code corresponding to MyRecordID. 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.
    entity.MyRecordID=outlookItem.<outlookProperty>;
                         
    Note: <outlookProperty> is the OutlookProperty of your choice
    Ex: entity.MyRecordID = outlookItem.Subject;
    
    

    MyRecordID is the name of the newly added property in the OData service.

  4. Navigate to MapUserPropertiesToEntity method in the TimeMgmtBusinessApplication.cs, and add the code corresponding to MyRecordID. 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.
    userProperty = userProperties[OutlookUtilities.GetUserPropertyName("MyRecordID")];
     if (userProperty != null)
        {
           if (!string.IsNullOrEmpty(userProperty.Value))
              {
                entity.MyRecordID = userProperty.Value;
              }
           OutlookUtilities.CleanUpResources(userProperty);
        }
    
  5. In the UserPropertiesTab.cs file navigate to the method LoadCustomFieldsDataGrid. This method is responsible for adding properties to the data grid, which shows the data on the user properties tab.
  6. Update the code to include fields that are added to OData service: Upgrade_AddProperties
  7. Now, the already existing, older Outlook items, which are still based on Version 1, must be updated. Refer the steps in Upgrading Older Outlook Items to upgrade the Outlook items.
  8. Build and install new GWM Outlook Add-in in Microsoft Outlook. See Creating an Installer for a GWM Visual Studio Add-In to create a new installer for more information.
  9. Open Microsoft Outlook, try to access the individual Outlook items and then verify that the fields that were added to the OData service are present.