Requirement:
Need to set a reminder programmatically, from a custom workflow action.
Sitecore Step 1: Create a workflow action within the workflow which is set to that item template.
Create a workflow. (I used the default sample workflow).
You can find how to create the workflow action in sitecore cookbook: http://sdn.sitecore.net/upload/sitecore6/workflow_cookbook_a4.pdf.
Sitecore Step 2: Provide Type String
Select the created workflow action.
In the Type String field provide the following details.
namespace.class_name, dll_name
Ex: TestWorkflow.SetReminder, TestWorkflow
Coding
public class SetReminder
{
public void Process(WorkflowPipelineArgs args)
{
var item = args.DataItem;
if (item != null)
{
using (new Sitecore.SecurityModel.SecurityDisabler())
{
item.Editing.BeginEdit();
try
{
item.Fields["__reminder text"].Value = "Review this item";
Sitecore.Data.Fields.DateField dateField = item.Fields["__reminder date"];
DateTime date = DateTime.Today.AddYears(1);
if (dateField != null)
{
dateField.Value = string.Format("{0}{1}{2}T{3}", date.Year, date.Month, date.Day,
date.ToString("hhmmss"));
}
}
finally
{
item.Editing.EndEdit();
}
}
}
}
No comments:
Post a Comment