2013 Workflow Task Links Redirect to Edit Form

May 28
2013 Workflow Task Links Redirect to Edit Form

Note:  The 2010 workflow engine opens to an edit form natively, so this post only applies to those of you that need to use the 2013 workflow for your approval process.

If your end-users are like mine, they don't appreciate having to click "Edit Item" in the ribbon in order to approve a task which they clicked on from their email notification.  I'm not a fan of it either, so here's a clever work-around to keep everyone happy.

  1. Open SharePoint Designer 2013 and navigate to your Tasks list where workflow is creating your assigned workflow tasks.
  2. Click the New... menu button in the Forms section
    Blog-TaskRedirectEdit01.png
  3. Give your new form a name, select the radio button by Display item form, check the box next to Set as default form for the selected type, and select the Workflow Task (SharePoint 2013) content type (assuming that is the content type you're using for your workflow tasks) and click the OK button.
    Blog-TaskRedirectEdit02.png
  4. Open the new form in Code view by clicking on the form name, then click the Advanced Mode button in the ribbon to open up the form for editing.
  5. Paste the following javascript AFTER the <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> line (approx line 14):
    <script type="text/javascript">
    <!--
    var origUrl = window.location.toString();
    var editUrl = origUrl.replace("CustomDisplayForm","EditForm");
    window.location = editUrl;
    //-->
    </script>
    Blog-TaskRedirectEdit03.png
  6. Save the changes to your form and then test by navigating to your list and clicking on the link to your task...it should be redirected to the Edit form via your new custom display form script.  This also means that when the end user clicks the link to the task from their email notification, the link will take them directly to the edit form page to approve/reject.
    Blog-TaskRedirectEdit04.png