none
ContentType with Expiration Policy and custom workflow not writing to central list RRS feed

  • Question

  • Hi: I've built a simple sequential workflow that is triggered by the retention policy used by a content type. The workflow takes the metadata of the current item and copies it to a purge log list located on a different site collection.

    Having a hard time debugging this because of the retention policy relies on two timer jobs: information management and expiration policy. Attach the debugger to the w3wp and owetimer process but does not reliably catch the activated workflow.

    My workflow history list for each file shows the workflow completed successfully. The meat of the workflow is a codeactivity that collects the data from the current item and updates a central list. That list is showing zero items after the process completes. Is it the code located in the codeactivity?

    I removed all of the exception handling to simplify what's being shown.

    public Workflow1()
    {
    InitializeComponent();
    }

    public Guid workflowId = default(System.Guid);
    public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();

    string purgeLogListPath = @"http://shptserver/sites/sp";
    string listPath = @"http://shptserver/sites/sp/Lists/PurgeLog/AllItems.aspx";

    private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
    {
    }

    private void codeActivity1_ExecuteCode(object sender, EventArgs e)
    {
      SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite site = new SPSite(purgeLogListPath))
        {
           try
           {
             SPWeb web = site.OpenWeb("/");
             SPList list = web.GetListFromUrl(listPath);
             DateTime today = DateTime.Now;

             SPListItem item = list.Items.Add();

             item["Title"] = onWorkflowActivated1.WorkflowProperties.Item.DisplayName;
             item["Encoded Absolute URL"] = onWorkflowActivated1.WorkflowProperties.ItemUrl;
             item["Content Type"] = onWorkflowActivated1.WorkflowProperties.Item.ContentType.Name;
             item["Date Purged"] = today.ToString("MMMM dd yyyy");
             item["DateTime Purged"] = today.ToString("MMMM dd yyyy hh:mm:ss");

             item.Update();
             }
             catch (Exception ex)
             {
             string errorEntry = ex.Message;
             }
             }
             });
         }
        }

    Wednesday, November 14, 2012 10:11 PM

All replies