How to open directly workflow task list edit form in SharePoint task list?

In this SharePoint workflow tutorial, how we can Send Task Form URL inside the Email in SharePoint Designer 2013 Workflow. And also we will discuss we can open directly task list edit form in SharePoint 2013/Online workflow.

We can directly open the SharePoint task list edit form in SharePoint Online/2013 visual studio workflow or designer workflow by using JavaScript code.

Open directly workflow task list edit form in SharePoint 2013/Online task list

Recently we were working in visual studio 2015 workflow for SharePoint online site. Here we had created a few tasks, and our requirement was that if the user clicks directly from the email from the Approve/Reject link then directly it should open the Edit form of the task.

We were using the below workflow variables to generate the Approve\Reject link.

<a href='%TaskSpecial: TaskUrl%'><b>Approve / Reject</b></a>

The above link will open the display form when any user clicks on the Approve/Reject link.

Let us say our task list display form URL is like below:

https://onlysharepoint2013.sharepoint.com/sites/Bhawana/Lists/MyTasks/DispForm.aspx?ID=1

One solution we can do is we can write the below code inside a script editor web part and put inside the particular task list’s display form.

<script language=”javascript” type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js”></script>
<script language=”javascript” type=”text/javascript”>

$(document).ready(function () {

var origUrl = window.location.toString();
var editUrl = origUrl.replace(“MyTasks/DispForm”,”MyTasks/EditForm”);
window.location = editUrl;

});
</script>

Or you can also put the below code inside the master page.

<script type=”text/javascript”>
var origUrl = window.location.toString();
var editUrl = origUrl.replace(“MyTasks/DispForm”,”MyTasks/EditForm”);
window.location = editUrl;
</script>

Now, whenever the user clicks on Approve/Reject button from the email body it will open the Edit form directly.

But one problem you will face is even if you try to open the Display form in the task list itself it will also redirect to the Edit form. So the user will not be able to see the Display form ever.

To solve the issue you can pass some query string parameter in the link in the email approve/reject link and then you can check if the above string contains the particular string then only you redirect.

Basically, you can do some string operation to handle that.

Send Task Form URL inside the Email in SharePoint Designer 2013 Workflow

In this SharePoint tutorial, we will discuss how to send task form URL inside the Email in SharePoint designer 2013 workflow in SharePoint Online/2013/2016.

We can add task form URL inside in SharePoint 2013 designer workflow email. In the designer workflow, we wanted to send the task item URL in the email body so that the user can click on that and open the task form.

You can use the below variable in the email body which will generate the task list form URL.

[%Current Task:Form_URN%]

You can also send like below,

<a href="http://Site URL/Lists/Tasks/EditForm.aspx?ID=[Item ID]">Edit item</a>

Once the user approves/rejects, the user will be redirected to the task list. But sometimes you might get the requirement to redirect to the source list instead of the task list.

In those requirements you can append the Source parameter like below:

[%Current Task:Form_URN%]&Source=https://onlysharepoint2013.sharepoint.com/sites/Bhawana/Lists/Announcements/AllItems.aspx

You may like following SharePoint designer workflow tutorials:

Hope this will be helpful to send Edit Task Form URL inside the Email in SharePoint Designer 2013 Workflow.

>