How To: Customize Sample Profile-Based Form Feature

Applies to: Duet Enterprise for Microsoft SharePoint and SAP Server 2.0 | Office 2010 | SharePoint Foundation 2010 | SharePoint Server 2010

In this article
Customizing the Solution
Importing OBAExtensionsSDK.wsp into Visual Studio
Customizing the Calendar Web Part
Customizing the User Profile-Based Form Web Part
Deploying the Modified Solution Package

Feature Pack 1 for Duet 1.0 provides a solution package (OBAExtensionsSDK.wsp) that comprises the Sample Profile–Based Form feature. Before deploying this solution, you must customize some portions of the solution.

These customizations are needed to allow the calendar and profile-based form Web Part to display data from the SAP system.

Customizing the Solution

To customize the solution, perform the following tasks:

  • Import the OBAExtensionsSDK.wsp solution file into Visual Studio

  • Customize the Calendar Web Part

  • Customize the User Profile-Based Form Web Part

  • Deploy the modified solution package

Importing OBAExtensionsSDK.wsp into Visual Studio

To work with the BDC model file, the solution must be imported into Visual Studio by using the Import Solution template.

Customizing the Calendar Web Part

The Calendar Web Part provided with Feature Pack 1 for Duet Enterprise 1.0 works simply by providing a calendar view of an already created external list.

The following properties must be set before the solution can be deployed:

  • OutlookItemType

  • Start

  • End

  • Subject

  • Location

  • Body

  • HideFieldForProfiles

  • UserProfilePropertyName

OutlookItemType Property

The OutlookItemType property of the entity indicates the Outlook item type to which this entity maps. This is a property used by BCS in SharePoint 2010 when an external list that is based on the entity is taken offline in Outlook.

For this solution to work, the OutlookItemType property must be present. Its value must be set to Appointment if the entity instances for an entity need to be displayed in the Calendar Web Part.

Start and End Properties

The three bold lines in the following code show the annotations that you must add to the specific finder method of the entity. These annotations are used by BCS to map the fields for an entity to the properties of an Outlook item when an external list that is based on the entity is taken offline in Outlook.

The same annotations are used to render the entity instances in the Calendar Web Part. These show that the StartTime and EndTime fields of the entity are mapped to the Start and End properties for an Outlook appointment item.

Note

Start and End strings are case-sensitive.

Other fields specified in the entity may be mapped to properties of an Outlook appointment, but only Start and End are required. All other properties are optional.

<Method IsStatic="false" Name="GetSpecificTimeEntry">
  <Parameters>
    <Parameter Direction="In" Name="timeEntryId">
      <TypeDescriptor TypeName="System.String" IdentifierName="Id" Name="timeEntryId" />
    </Parameter>
    <Parameter Direction="Return" Name="GetSpecificTimeEntry">
      <TypeDescriptor TypeName="CannedDataService.TIMAEntryGetSpecResponse, TIMAService" 
         Name="GetSpecificTimeEntry">
        <TypeDescriptors>
          <TypeDescriptor TypeName="CannedDataService._iwtng_TIMAEntry, TIMAService" 
             Name="EsOutput">
            <TypeDescriptors>
              <TypeDescriptor TypeName="System.String" ReadOnly="true" 
                 IdentifierName="Id" Name="Id" />
              <TypeDescriptor TypeName="System.DateTime" Name="StartTime">
                <Properties>
                  <Property Name="OfficeProperty" Type="System.String">Start</Property>
                  <Property Name="SPCustomFieldType" Type="System.String">
                     ObaDateTimeField
                  </Property>
                </Properties>
                <Interpretation>
                  <NormalizeDateTime LobDateTimeMode="UTC" />
                </Interpretation>
              </TypeDescriptor>
              <TypeDescriptor TypeName="System.DateTime" Name="EndTime">
                <Properties>
                  <Property Name="OfficeProperty" Type="System.String">End</Property>
                  <Property Name="SPCustomFieldType" Type="System.String">
                     ObaDateTimeField
                  </Property>
                </Properties>
                <Interpretation>
                  <NormalizeDateTime LobDateTimeMode="UTC" />
                </Interpretation>
              </TypeDescriptor>
              <TypeDescriptor TypeName="System.String" Name="Subject">
                <Properties>
                  <Property Name="OfficeProperty" Type="System.String">Subject</Property>
                  <Property Name="SPCustomFieldType" Type="System.String">
                     ObaTextField
                  </Property>
                </Properties>
              </TypeDescriptor>
              <TypeDescriptor TypeName="System.String" Name="Body">
              </TypeDescriptor>
              <TypeDescriptor TypeName="System.String" Name="AllDayEvent" />
              <TypeDescriptor TypeName="System.String" Name="Absence">
                <Properties>
                  <Property Name="HideFieldForProfiles" Type="System.String">
                     MyProfile1;MyProfile2
                  </Property>
                </Properties>
              </TypeDescriptor>
              <TypeDescriptor TypeName="System.String" Name="Network">
                <Properties>
                  <Property Name="HideFieldForProfiles" Type="System.String">
                     MyProfile1,MyProfile2
                  </Property>
                </Properties>
              </TypeDescriptor>
              <TypeDescriptor TypeName="System.String" Name="ReceiverIO" />
              <TypeDescriptor TypeName="System.String" Name="ReceiverOrder" />
              <TypeDescriptor TypeName="System.String" Name="ReceiverWBSElement" />
              <TypeDescriptor TypeName="System.String" Name="SenderCostCenter" />
              <TypeDescriptor TypeName="System.String" Name="Task" >
              </TypeDescriptor>
              <TypeDescriptor TypeName="System.String" Name="WageType" />
            </TypeDescriptors>
          </TypeDescriptor>
        </TypeDescriptors>
      </TypeDescriptor>
    </Parameter>
  </Parameters>
  <MethodInstances>
    <MethodInstance Type="SpecificFinder" 
       ReturnParameterName="GetSpecificTimeEntry" 
       ReturnTypeDescriptorPath="GetSpecificTimeEntry.EsOutput" 
       Default="true" 
       Name="ReadEmployeeTimeQueryByID" 
       DefaultDisplayName="Read Item TimeEntry" />
  </MethodInstances>
</Method>

Subject, Location, and Body Properties

The Subject, Location, and Body properties are used during rendering of the items in the Calendar Web Part to provide contextual information.

<TypeDescriptor TypeName="System.String" Name="Subject">
  <Properties>
    <Property Name="OfficeProperty" Type="System.String">Subject</Property>
  </Properties>
</TypeDescriptor>

HideFieldForUserProfiles Property

Sometimes it is necessary or desirable to hide certain entity fields. For instance, a column containing personnel information should be viewable only by a manager. The HideFieldForUserProfiles property enables a developer to specify which fields to hide and for which profiles.

The following changes demonstrate how to hide a field for specified profiles.

<TypeDescriptor TypeName="System.String" Name="Absence">
    <Properties>
       <Property Name="HideFieldForProfiles" Type="System.String">MyProfile1;MyProfile2</Property>
     </Properties>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="Network">
   <Properties>
      <Property Name="HideFieldForProfiles" Type="System.String">MyProfile1,MyProfile2</Property>
   </Properties>
</TypeDescriptor>

The list of SAP roles or profiles provided for this property should be delimited by either semicolons or commas. Profile names are case-sensitive.

Customizing the User Profile-Based Form Web Part

To customize the form Web Part, you must set the UserProfilePropertyName and HideFieldForProfiles properties. You can also prepopulate the form fields.

UserProfilePropertyName Property

The UserProfilePropertyName is a custom annotation specific to Feature Pack 1 for Duet Enterprise 1.0. It specifies the name of the property in the User Profile store that contains the SAP roles for a user in SharePoint. Feature Pack 1 functionality requires SAP roles for a user to be synced to the User Profile store in SharePoint. A custom property in the User Profile store contains the SAP roles for each user. In this solution, this property is named "TIMAProfile", as shown in the following example.

<Entity Namespace="SAP.Office.DuetEnterprise.Time" Version="1.0.0.0" EstimatedInstanceCount="10000" Name="Time" DefaultDisplayName="TimeEntry">
   <Properties>
      <Property Name="UserProfilePropertyName" Type="System.String">TIMAProfile</Property>
    </Properties>

HideFieldForProfiles Property

The HideFieldForProfiles property hides fields for specific SAP roles or profiles. In this example, MyProfile1 and MyProfile2 represent SAP role or profile names. When a user views or creates or edits an item in an external list by using the User Profile–Based Form Web Part, the SAP roles or profiles for the user are retrieved from the User Profile store, and the field is displayed accordingly. In this example, if the user has the SAP role "MyProfile1", the "Absence" and "Network" fields do not appear on the view, create, and edit forms. If a field has no annotations, it is shown by default.

The following modifications are done to the specific finder method of the entity.

<TypeDescriptor TypeName="System.String" Name="Absence">
    <Properties>
       <Property Name="HideFieldForProfiles" Type="System.String">
          MyProfile1;MyProfile2
       </Property>
     </Properties>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="Network">
   <Properties>
      <Property Name="HideFieldForProfiles" Type="System.String">
         MyProfile1,MyProfile2
      </Property>
   </Properties>
</TypeDescriptor>

You must also provide a list of the SAP roles that you added to the HideFieldForProfiles property to the SharePoint administrator who is deploying the solution. The SharePoint administrator adds the appropriate SAP role to the user profiles when deploying the user profile–based list solution.

Prepopulating Values in a Create Form

For the convenience of users, you can prepopulate the form fields by making some modifications to the BDC model.

To prepopulate the fields, map the Start, End, Subject, Location, and Body properties as shown in the following code. The properties must also be added to the BDC model.

<TypeDescriptor TypeName="System.DateTime" Name="StartTime">
   <Properties>
      <Property Name="OfficeProperty" Type="System.String">Start</Property>
      <Property Name="SPCustomFieldType" Type="System.String">
         ObaDateTimeField</Property>
   </Properties>
</TypeDescriptor>

<TypeDescriptor TypeName="System.String" Name="Subject">
   <Properties>
      <Property Name="OfficeProperty" Type="System.String">Subject</Property>
      <Property Name="SPCustomFieldType" Type="System.String">
         ObaTextField</Property>
   </Properties>
</TypeDescriptor>

Note

For string fields the property value is "ObaTextField", for date/time fields the value is "ObaDateTimeField", and for Boolean fields it is "ObaBooleanField".

Deploying the Modified Solution Package

After you complete your customizations, you can deploy the solution file to the solution gallery in SharePoint, or you can repackage it as a solution file.

Deploying the Solution Directly to SharePoint

  1. From the Build menu in Visual Studio, select Deployprojectname.

  2. Visual Studio deploys the package, and it appears in the solutions gallery in SharePoint.

Deploying the Solution as a Solution Package

  1. From the Build menu in Visual Studio, select Package.

  2. Find the .wsp file in the build directory for your project.