Sharepoint Drop Down Context Menu Workflow Shortcut
It’s fairly simple to add custom menu options to the drop down context menu in sharepoint library/list views. One useful example maybe to provide a shortcut to start workflows, instead of opening the workflow page; selecting the desired workflow and clicking the Start button.
To do this we need to add some Javascript to the page. Edit the page and add a Content Editor Web Part, hide it by clearing its Layout / Visible on Page checkbox. Edit the Content Editor Web Part Source and insert the following Javascript:
<script language="javascript">
function Custom_AddDocLibMenuItems(m, ctx)
{
var strDisplayText = "Send for Review";
var strAction = "http://sharepointserver/Workflows/Send%20for%20Review/Send%20for%20Review.aspx?List=14987b66-90be-4693-aafd-94bc6ba8f18e&amp;ID=24&amp;TemplateID={dcbbce95-46dc-4b58-b69e-a99b9ea6a698}&amp;Source=http%3A%2F%2Fsharepoint%2Edomain%2Ecom%2FWIP%2FForms%2FOpen%2Easpx%3FPageView%3DShared";
var strImagePath = "";
var start = strAction.indexOf("&amp;ID=")+4
var prefix = strAction.substr(0, start)
var suffix = strAction.substr(strAction.indexOf("&amp;", start), strAction.length)
strAction = "location.href = '" + prefix + currentItemID + suffix + "'"
// Add our new menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);
// add a separator to the menu
CAMSep(m);
return false;
}
</script>
If you update the workflow you will need to edit the strAction property as the URL will change. Also if you try to start a workflow using the shortcut on an item where the workflow is already running the workflow will error. If there is a way to check if workflow is running on an item I’d be interested to know how it’s done!
admin :: Jun.12.2008 :: Uncategorized :: 6 Comments »
6 Responses to “Sharepoint Drop Down Context Menu Workflow Shortcut”
Leave a Reply
You must be logged in to post a comment.
Thanks for the post. I was using Custom_AddListMenuItems …
For your question, my function is pointing to another custom aspx page ,with C# code (request.open(“GET”, builtURL, false);). I send to that page in query string my list and the item. That way I’m sure you could check the workflow status on the item.
Dear Ian ,
I’m looking for a way to disable the whole drop down menu on an announcements list web part added on the homepage.
Users should be remain able to click on the item to read it , but the drop down menu is confusing for users .
Can this dropdown behavior be stopped in any way?
Thank You
Hi,
I doubt that this javascript code will start the workflow. My understanding is, it will redirect to custom webpart page only. Then user will have to click on the start button.
Thanks,
Manas
Hi Ian,
I have already used this technique but note that i found that u cant use startworkflow inside formload event
Hi..
After clicking the menu item I am redirected to page where we have to manually start the workflow.The workflow does not start automatically?I have used the same code snippet.
Am I missing something?
Hi All,
I found a solution to start the workflow from list view page (AllItems.aspx). I am calling the StartWorkflow method in Workflow webservice through XmlHttpRequest.
Thanks,
Manas