I wanted to create a “copy to new item” functionality for a SharePoint list.
Steps I came up with:
- The first thing I had to do was add a link to the context menu (I learned that it is called an ECB) and have it point to the NewForm.aspx.
- Once I got that, I could append a querystring variable to the url that contained the “Source ID” of the item to copy and the name of the current list.
- Then I would grab that querystring value on the other side – in the NewForm.aspx page
- Next I would use that variable to query the SharePoint List via SOAP
- Inject the results the into the form
Here is my script (add to a CEWP, I already have the jquery pointers to google in a Delegate control)
<script language="javascript"> function Custom_AddListMenuItems(m, ctx) { var editURL = window.location.protocol + "//" + window.location.host + ctx.listUrlDir + "/NewForm.aspx?SourceID=" + currentItemID + "&ListName=" + ctx.ListTitle; CAMOpt(m, "Copy To New Item" ,"window.location=('" + editURL + "');" , "/_layouts/images/Copy.GIF"); CAMSep(m); } </script>
More to come.
Comments are closed.