How to open directly task list edit form in SharePoint 2013 or SharePoint Online task list?

Check out Best Alternative to InfoPath


In this post, we will discuss how we can open directly task list edit form in SharePoint 2013 or SharePoint online.


Recently we were working in visual studio 2015 workflow for SharePoint online site. Here we had created 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

Also you can check:
SharePoint online or SharePoint 2013 hide content type in Edit Form using jQuery

Get all SharePoint Users in CSV File from Farm using PowerShell in SharePoint

Working with Enterprise Metadata and Keywords Settings for List and Document library in SharePoint Online

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 when ever 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.


Hope this will be helpful.


You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →