Archives

One of the little annoyances with SharePoint workflows is that tasks often open in a display-only mode by default, especially when you are following an email link. The extra click needed to place the task in "Edit" mode causes confusion and wastes time.

In SharePoint 2007 and 2010, you could get around this by customizing the task URL in a notification email, or by having users use the "Open this Task" feature of the Outlook client. Unfortunately neither of these options work with 2013 workflow tasks. So I came up with a quick little trick to get around the issue. It is just a custom display form that secretly redirects to the EditForm. This code is tested with SharePoint 2013 and Office 365 / SharePoint Online.

One Click Approval for SharePoint 2013 Tasks:

(Screenshots below)

1. Open the task list in SharePoint Designer and create a new List Form

2. In the Create New List Form window, set the Filename as “RedirectToEditForm”, the type as Display, and check “Set as the default for the selected type”. Also pick your Workflow Task content type.

3. Open the Form in Designer so that the code is displayed, then click the “Advanced Mode” button in the ribbon bar. This will open the entire page for edits.

4. Insert the following javascript directly after the line <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> (this is around line 15)

That is it! Now whenever someone opens a task, the EditForm is automatically displayed and only one click is needed to approve or reject the task. The redirection should occur before the first form renders so end users won’t notice what is going on.

Comments

I've been looking for a solution so that a user doesn't have to click Edit every time. Now I only need to look for the other issue I have where when a user clicks on the link from their email that they've been assigned a task, it automatically opens the task instead of showing a list of other tasks.

Thank you very much for this simple and extremely useful solution. Saved me a lot of time.

Question: I'd like to redirect users to the home page (instead of the workflow task list) after completing the task. I thought of reusing your script in the edit form itself. I want to specify that it change the url after "sourece=" from something like "https%3A%2F%2Fmydomain%2Esharepoint%2Ecom%2FLists%2FWorkflow%2520Tasks%2FAllItems%2Easpx" to something like "https%3A%2F%2Fmydomain%2Esharepoint%2Ecom" . I'd like to know what you think. is there a better way of achieving this?

how frustrating the url to the edit form isn't available OOB or that you cannot get the task ID from within the task either would allow this without code changes but nonetheless excellent work, saved me hours of end user confusions!

Hey I saw Dean's comment about the error message Type 'Microsoft.SharePoint.WebControls.UIVersionedContent' does not have a public property named 'script'. - and managed to get the same thing.

If you see this, you made a mistake with where you inserted the script block. Make sure it is after the <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> tag but BEFORE the <SharePoint:UIVersionedContent UIVersion="4" runat="server"> tag.

This has been really bugging me and have tried several options to workaround all the problems and get a workflow approval process which my business users won't throw back at me. The final piece of the puzzle was how to ensure that the Approve Task link which gets emailed out would actually take the user directly to editable version of the task which contains the Approve & Reject buttons. Have spent the last couple of days wrestling with this problem and trying different options, finally found this article and solved that problem in 5 mins

When I try this in SharePoint Online, I get Type 'Microsoft.SharePoint.WebControls.UIVersionedContent' does not have a public property named 'script'. Any idea what I might be doing wrong or how to fix?TIADean

Hi this is really great and works well.Once I try to hide items from the task form through, something say %complete and status the approve and reject buttons disappear. Any suggestions why this might be happening?

After 2 hours of trying to get the URL formed in the Workflow Email using the ID (where the Q@#$$% is the ID of the Related Task?????), your workaround worked perfectly! I can't believe Microsoft doesn't provide either the Task ID in a variable for use in the Workflow Task email or this redirect functionality OOTB.