You can extend the generated code on completing and building of the GWM Outlook add-in template.
To extend the code, create a new proxy and extension classes for the service and implement the IValueHelpData interface, which is provided in your GWM Outlook add-in project.
For example, you can extend the generated code by adding a Value Help to enable users to select the recipient when forwarding a task.
The Add SAP Service Reference window appears.
class UserCollectionValueHelpData : IValueHelpData { }
public DataTable GetValueHelpData(string baseUrl) { DataTable valueHelpData = new DataTable(); foreach (string propertyName in userservice.User.SAPPropertyAttributes.Keys) { PropertyMetadata propertyMetadata = userservice.User.SAPPropertyAttributes[propertyName]; DataColumn column = new DataColumn(propertyName); column.Caption = propertyMetadata.Label; valueHelpData.Columns.Add(column); } var serviceContext = new userservice.USERSERVICE(new Uri(baseUrl)); var serviceResponse = serviceContext.UserCollection.Execute() as QueryOperationResponse<userservice.User>; foreach (var entity in serviceResponse) { DataRow dataRow = valueHelpData.NewRow(); dataRow[valueHelpData.Columns["firstname"]] = entity.firstname; dataRow[valueHelpData.Columns["lastname"]] = entity.lastname; dataRow[valueHelpData.Columns["username"]] = entity.username; dataRow[valueHelpData.Columns["fullname"]] = entity.fullname; valueHelpData.Rows.Add(dataRow); } return valueHelpData; }
The ValueHelpFactory.cs class contains a factory method which initializes the appropriate value help collection class.
internal static IValueHelpData GetValueHelp(string proxyName, string collectionname) { IValueHelpData valuehelpData = null; switch (proxyName) { case "userservice": switch (collectionname) { case "UserCollection": valuehelpData = new UserCollectionValueHelpData(); break; } break; } return valuehelpData; }
valuehelpData = new UserCollectionValueHelpData();
private void button1_Click(object sender, EventArgs e) { ServiceDetails serviceDetail = ConfigurationReaderHandler.Instance.GetServiceDetails("userservice"); ValueHelpForm f4HelpForm = new ValueHelpForm(serviceDetail.Url,"userservice","UserCollection"); if (f4HelpForm.ShowDialog() == DialogResult.OK) { txtForwardTo.Text = f4HelpForm.GetSelectedValueHelp("username"); } }