Posts RSS Comments RSS 16 Posts and 26 Comments till now

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;amp;ID=24&amp;amp;TemplateID={dcbbce95-46dc-4b58-b69e-a99b9ea6a698}&amp;amp;Source=http%3A%2F%2Fsharepoint%2Edomain%2Ecom%2FWIP%2FForms%2FOpen%2Easpx%3FPageView%3DShared";

var strImagePath = "";

var start = strAction.indexOf("&amp;amp;ID=")+4
var prefix = strAction.substr(0, start)
var suffix = strAction.substr(strAction.indexOf("&amp;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!

6 Responses to “Sharepoint Drop Down Context Menu Workflow Shortcut”

  1. on 22 Oct 2008 at 3:26 pmJL

    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.

  2. on 31 Oct 2008 at 4:48 amMiled

    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

  3. on 18 Dec 2008 at 10:08 amManas

    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

  4. on 05 Mar 2009 at 3:57 pmshireef

    Hi Ian,
    I have already used this technique but note that i found that u cant use startworkflow inside formload event

  5. on 22 Apr 2009 at 7:04 pmpriyanka

    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?

  6. on 19 Jun 2009 at 9:58 amcontact_manas

    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

Trackback this post | Feed on Comments to this post

Leave a Reply

You must be logged in to post a comment.