I am trying to update a list on another site using a special workflow action. Sites are within the same site collection. I have successfully deployed custom actions on a SharePoint server. When I start a workflow that contains this action, the workflow completes successfully without errors. I am sure that the action is performed because I see the result of the lines that contain service.LogToHistoryList()the history of workflows in the log, and they contain the expected values. The problem is that the goal list item is not actually being updated. The following is a snippet of code that is designed to update a list item.
try
{
ISharePointService service = (ISharePointService)executionContext.GetService(typeof(ISharePointService));
service.LogToHistoryList(this.WorkflowInstanceId, SPWorkflowHistoryEventType.WorkflowComment, 0, TimeSpan.Zero, "Debugging Output", SiteUrl, string.Empty);
service.LogToHistoryList(this.WorkflowInstanceId, SPWorkflowHistoryEventType.WorkflowComment, 0, TimeSpan.Zero, "Debugging Output", List, string.Empty);
service.LogToHistoryList(this.WorkflowInstanceId, SPWorkflowHistoryEventType.WorkflowComment, 0, TimeSpan.Zero, "Debugging Output", Column, string.Empty);
service.LogToHistoryList(this.WorkflowInstanceId, SPWorkflowHistoryEventType.WorkflowComment, 0, TimeSpan.Zero, "Debugging Output", Value, string.Empty);
service.LogToHistoryList(this.WorkflowInstanceId, SPWorkflowHistoryEventType.WorkflowComment, 0, TimeSpan.Zero, "Debugging Output", updateCol, string.Empty);
service.LogToHistoryList(this.WorkflowInstanceId, SPWorkflowHistoryEventType.WorkflowComment, 0, TimeSpan.Zero, "Debugging Output", updateVal, string.Empty);
ClientContext clientContext = new ClientContext(SiteUrl);
SP.List oList = clientContext.Web.Lists.GetByTitle(List);
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Geq><FieldRef Name='"+Column+"'/>" +
"<Value Type='String'>"+Value+"</Value></Geq></Where></Query><RowLimit>1</RowLimit></View>";
ListItemCollection collListItem = oList.GetItems(camlQuery);
clientContext.Load(collListItem);
clientContext.ExecuteQuery();
foreach (ListItem oListItem in collListItem)
{
oListItem[updateCol] = updateVal;
oListItem.Update();
clientContext.Load(oListItem);
clientContext.ExecuteQuery();
}
return ActivityExecutionStatus.Closed;
}
catch (Exception ex)
{
ISharePointService service = (ISharePointService)executionContext.GetService(typeof(ISharePointService));
if (service == null)
{
throw;
}
service.LogToHistoryList(this.WorkflowInstanceId,SPWorkflowHistoryEventType.WorkflowError, 0, TimeSpan.Zero,"Error Occurred", ex.Message, string.Empty);
return ActivityExecutionStatus.Faulting;
}