Custom SharePoint Context Action links and Modal Dialogs

After a question from “Chris” on a previous post, I thought it was better to post the whole solution.

Abstract of Chris’ question (original comment):

 

“…using SharePoint Designer, I have added a few of my own custom items in the context menu. They work fine ... but they DON'T open up in the same 'modal dialog' - they simply open on my SharePoint screen.”

 

The solution is dead simple. You can use the JavaScript from my previous post directly in SharePoint Designer.

First, add a new context item on your list:

image

Then, change the mode to Navigate to Url and add the script as (change to the location of your list):

javascript:SP.UI.ModalDialog.showModalDialog({ url: "/Lists/Announcements/NewForm.aspx", title: "Add item" }); return false;

image

You can optionally add the other parameters just as the original post states to add window width and height.