Hi
We have created a provider-hosted App.The app contains a list,workflow definition and a remote event receiver. We are trying to start the workflow from the remote event receiver .
We are getting an exception on the code which will start the workflow and after calling context.Executequery
instanceService.StartWorkflowOnListItem(subscriptions[0], properties.ItemEventProperties.ListItemId, args);
context.ExecuteQuery();
{The request was aborted: The request was canceled. Client ActivityId : d2d4349c-9d84-b06d-6127-af6b0a47fa81.
at Microsoft.Workflow.Client.ClientHelpers.SendRequest[T](HttpWebRequest request, T content)
at Microsoft.Workflow.Client.WorkflowManager.StartInternal(String workflowName, WorkflowStartParameters startParameters)
at Microsoft.SharePoint.WorkflowServices.FabricWorkflowManagementClient.StartInstance(String serviceGroupName, String workflowName, String monitoringParam, String activationKey, IDictionary`2 payload)
at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.StartWorkflow(WorkflowSubscription subscription, IDictionary`2 payload)
at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.StartWorkflowOnListItem(WorkflowSubscription subscription, Int32 itemId, IDictionary`2 payload)
at Microsoft.SharePoint.WorkflowServices.WorkflowInstanceServiceServerStub.StartWorkflowOnListItem_MethodProxy(WorkflowInstanceService target, XmlNodeList xmlargs, ProxyContext proxyContext)
at Microsoft.SharePoint.WorkflowServices.WorkflowInstanceServiceServerStub.InvokeMethod(Object target, String methodName, XmlNodeList xmlargs, ProxyContext proxyContext, Boolean& isVoid)
at Microsoft.SharePoint.Client.ServerStub.InvokeMethodWithMonitoredScope(Object target, String methodName, XmlNodeList args, ProxyContext proxyContext, Boolean& isVoid)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.InvokeMethod(Object obj, String methodName, XmlNodeList xmlargs, Boolean& isVoid)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessMethod(XmlElement xe)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessOne(XmlElement xe)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessStatements(XmlNode xe)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.Process()}
code is as follows and the line of code where we are facing the issue is highlighted
public void ProcessOneWayEvent(SPRemoteEventProperties properties)
{
if (properties.EventType != SPRemoteEventType.ItemAdded)
return;
// build client context using S2S
using (ClientContext context = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
Web web = context.Web;
// create a collection of name/value pairs to pass to the workflow upon starting
var args = new Dictionary<string, object>();
args.Add("RemoteEventReceiverPassedValue", "Hello from the Remote Event Receiver! - " + DateTime.Now.ToString());
WorkflowServicesManager wsm = new WorkflowServicesManager(context, web);
context.Load(wsm);
context.ExecuteQuery();
WorkflowSubscriptionService subscriptionService = wsm.GetWorkflowSubscriptionService();
context.Load(subscriptionService);
context.ExecuteQuery();
var subscriptions = subscriptionService.EnumerateSubscriptionsByList(properties.ItemEventProperties.ListId);
WorkflowInstanceService instanceService = wsm.GetWorkflowInstanceService();
context.Load(instanceService);
context.ExecuteQuery();
instanceService.StartWorkflowOnListItem(subscriptions[0], properties.ItemEventProperties.ListItemId, args);
context.ExecuteQuery();
}
}
Girish