Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting – HostForLIFE.eu :: Custom Action Menu In SharePoint ListItem
ECB Menu For SharePoint or Custom action menu is available for user access at different locations in SharePoint. It can be an icon/text, which can be used to implement functionality such as navigating to a landing page, starting a Workflow on an item or any custom action inside SharePoint.
By default SharePoint provides the default custom action like edit, delete and view item options.
Here we will be adding new ECB Menu as “Custom Edit Page” as shown in the below image.
On click of the Cusom Edit Link, it will be redirected to my custom edit page which I have created under list form.
Also, I am passing the ID of current list item as well as Source page URL from where it will be redirected back after performing action on redirected edit page.
Implementaion
It can be implemented with any list/library, however I have implemented it on list.
You can use any ScriptEditor/CEWP on your page and put all below scripts as is by just changing the list name and URL.
Full Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
<script language="javascript" type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function() { SP.SOD.executeFunc('sp.js', 'SP.ClientContext', AddCustomUserActionToECB); }); function AddCustomUserActionToECB() { var clientContext = new SP.ClientContext(); var oWeb = clientContext.get_web(); var oList = oWeb.get_lists().getByTitle('ComplainTracking'); var userCustomActionColl = oList.get_userCustomActions(); clientContext.load(oList, 'UserCustomActions', 'Title'); clientContext.executeQueryAsync(function() { var customActionEnumerator = userCustomActionColl.getEnumerator(); var foundAction = 0; while (customActionEnumerator.moveNext()) { var oUserCustomAction = customActionEnumerator.get_current(); if (oUserCustomAction.get_title() == 'Custom Edit Page') { //oUserCustomAction.deleteObject(); //clientContext.load(oUserCustomAction); //clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededdelete), Function.createDelegate(this, this.onQueryFailed)); foundAction = 1; break; } } if (foundAction == 0) { var oUserCustomAction = userCustomActionColl.add(); oUserCustomAction.set_location('EditControlBlock'); oUserCustomAction.set_sequence(100); oUserCustomAction.set_title("Custom Edit Page"); //oUserCustomAction.set_url("/sites/QA/SL_MI/SitePages/CustomSearch.aspx?ListId={ListId}&ItemId={ItemId}&ItemUrl={ItemUrl}"); oUserCustomAction.set_url("/sites/QA/SL_MI/Lists/ComplainTracking/Edit1.aspx?ID={ItemId}&Source=/sites/QA/SL_MI/SitePages/ListViewGrid.aspx"); oUserCustomAction.update(); clientContext.load(userCustomActionColl); clientContext.executeQueryAsync(); } }, function(sender, args) { console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); }); } </script> |
Print article | This entry was posted by Peter on May 24, 2018 at 7:14 am, and is filed under European SharePoint 2013 Hosting. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |