1

Is it possible to fire a Workflow from a hyperlink in an Email? For example:

I have an item which requires more steps than the basic 'Approval' Workflow. I would like Managers to be able to start the Approval/Rejected Workflow process depending on which link they click in the Request Email.

enter image description here

I understand that I could fire an Approval process within the Workflow, but I'd like to start these directly from the user's email client by clicking the Approve Link, or the Reject Link.

Is this possible?

0

You can do this with the JSOM.

This will get you started: https://msdn.microsoft.com/en-us/library/office/dn481315.aspx

I would write a page for kicking off each workflow that take params in the url and passes them into the JS function.

I am unable to share specific code with you here, but read through the below and see the basic process for building out the objects you will need when you get to the end where you kick off the workflow on the list item.

var startParameters = new Dictionary<string, object>();
workflowInstanceService.StartWorkflowOnListItem(firstWorkflowAssociation, listItemId, startParameters);
clientContext.ExecuteQuery();

Here is the full process:

// connect to the deployment service
var workflowDeploymentService = workflowServicesManager.GetWorkflowDeploymentService();

// get all installed workflows
var publishedWorkflowDefinitions = workflowDeploymentService.EnumerateDefinitions(true);
clientContext.Load(publishedWorkflowDefinitions);
clientContext.ExecuteQuery();

// find the first workflow definition
var firstWorkflowDefinition = publishedWorkflowDefinitions.First();

// connect to the subscription service
var workflowSubscriptionService = workflowServicesManager.GetWorkflowSubscriptionService();

// get all workflow associations
var workflowAssociations = workflowSubscriptionService.EnumerateSubscriptionsByDefinition(firstWorkflowDefinition.Id);
clientContext.Load(workflowAssociations);
clientContext.ExecuteQuery();

// find the first association
var firstWorkflowAssociation = workflowAssociations.First();

// connect to the instance service
var workflowInstanceService = workflowServicesManager.GetWorkflowInstanceService();

// start the workflow
var startParameters = new Dictionary<string, object>();
workflowInstanceService.StartWorkflowOnListItem(firstWorkflowAssociation, listItemId, startParameters);
clientContext.ExecuteQuery();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.