Thursday, September 17, 2009

Change default action of the workflow task in Sharepoint

It is good user exeprience if user can directly edit the task instead of going to View the task and then edit. or instead of going to ECB menu and then select edit item.

User should be edit the task using only single click. here are the steps to achieve this thing.:
Step1. Open master page. and put following javaScript code in the head part of the master page.
function GoToLink(elm)
{
try
{

if (elm.href==null)
return;
var ch=elm.href.indexOf("?") >=0 ? "&" : "?";
var srcUrl=GetSource();
if (srcUrl !=null && srcUrl !="")
srcUrl=ch+"Source="+srcUrl;
var editUrl, regExp;
var dispUrl = elm.href ;

regExp = /DispForm.aspx/i;
editUrl = dispUrl.replace(regExp, "EditForm.aspx");
var targetUrl= editUrl + srcUrl;

if (isPortalTemplatePage(targetUrl))
window.top.location=STSPageUrlValidation(targetUrl);
else
window.location=STSPageUrlValidation(targetUrl);
}
catch(e)
{
alert(e.description);
}
}


Step 2. Make Defer="false" in following markup code in the master page.

3. THe default action of task has been changed to edit item.

4, isnt it cool user experience??

1 comment:

Swati Jain said...

Please post the images also for better understanding..