0
我通過調用workflowManager.StartWorkflow()從SharePoint事件接收器以編程方式運行SharePoint工作流。SharePoint:在StartWorkflow()終止後訪問工作流變量
工作流程是在執行期間設置一些工作流變量。有沒有辦法在工作流程終止後訪問這些變量的最後一個值(例如,對StartWorkflow()的調用返回)?
以下是一個演示我的意圖我的示例代碼:
public override void ItemAdded(SPItemEventProperties properties)
{
SPWorkflow workflow = null;
SPWorkflowManager workflowManager = null;
try
{
base.ItemAdded(properties);
workflowManager = properties.OpenWeb().Site.WorkflowManager;
var workflowAssociation = properties.ListItem.ParentList.WorkflowAssociations[0];
workflow = workflowManager.StartWorkflow(properties.ListItem, workflowAssociation, "<Data></Data>");
// I can read any fields that were updated by the WF
SPListItem item = properties.ListItem.ParentList.GetItemById(properties.ListItemId);
string validationResult = (string) item["ValidationResult"];
// how can I access any workflow variables created during execution?
}
catch (Exception ex)
{
Debug.WriteLine(ex);
if (workflow != null && workflowManager != null)
{
SPWorkflowManager.CancelWorkflow(workflow);
}
throw;
}
}