Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Letzte Änderung: Freitag, 14. Mai 2010
Gilt für: SharePoint Server 2010
Im folgenden Beispiel wird die Implementierung einer benutzerdefinierten Codeaktion veranschaulicht.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.BusinessData.Runtime;
using System.Windows.Forms;
using outlookPIA = Microsoft.Office.Interop.Outlook;
namespace ContosoCustomer
{
public class CustomCodeAction
{
//Custom Code Action Method
//The parameters array contains the entity instance for current item as the first parameter.
public void NewCustomVisitTask(object[] parameters)
{
IEntityInstance iei = parameters[0] as IEntityInstance;
try
{
//Get values from current EntityInstance.
string CustomerFName = iei["FirstName"].ToString();
string CustomerLName = iei["LastName"].ToString();
//Create a new Outlook task Item through Outlook interop.
//Trusted Outlook interop object is set in CustomRibbonManger.
outlookPIA.TaskItem newCustomVisitTaskItem =
(outlookPIA.TaskItem)CustomRibbonManger.currentOutlookApplication.CreateItem(outlookPIA.OlItemType.olTaskItem);
//set task properties.
newCustomVisitTaskItem.Subject = "Custom Visit Task: " + CustomerFName + " " + CustomerLName;
newCustomVisitTaskItem.StartDate = DateTime.Now;
newCustomVisitTaskItem.DueDate = DateTime.Now.AddDays(7);
newCustomVisitTaskItem.Save();
//Display task item.
newCustomVisitTaskItem.Display(false);
}
catch (Exception)
{
MessageBox.Show("Cannot find Entity Instance related to this item");
}
}
}
}