Showing posts with label custom Action. Show all posts
Showing posts with label custom Action. Show all posts

Thursday, June 9, 2016

Show custom action in ribbon for only one list

Example Code:

<CustomAction ControlAssembly="CustomProject.Actions" 
                ControlClass="CustomProject.Actions" 
                ControlSrc="/_layouts/test/testPage.aspx" 
                Description="This is my custom action" 
                GroupId="MyCustomActions" 
                Id="f5bcd75e-23b9-4623-9a82-41cc7ceb10a6" 
                RegistrationId="MyMagicalList" 
                RegistrationType="List" 
                RequireSiteAdministrator="false" 
                Rights="AddListItems" 
                Sequence="1" 
                ShowInReadOnlyContentTypes="false" 
                ShowInSealedContentTypes="false" 
                Title="MyCustomAction">

EnabledScript parameter in CommandUIHandler, where you can put javascript code and check if specific page/list/view is loaded.

Example:

<CommandUIHandler 
  Command="Ribbon.ListItem.CustomGroup.Controls.BtnSayHello.Command"
  CommandAction="javascript:alert('Image ');"
  EnabledScript="javascript:
    function isEnable(){
      if(location.href.indexOf('AllItems.aspx') > 0){
        return true;
      }
      return false;
    }
    isEnable();"
/>

Wednesday, May 18, 2016

how to Change Custom List Close Button

$(document).ready(function() {

    var button = $("input[value=Close]");
    // change redirection behavior
        button.removeAttr("onclick");
        button.click(function() {
            var elementName = $(this).attr("name");
            var aspForm = $("form[name=aspnetForm]");
            var oldPostbackUrl = aspForm.get(0).action;
            var currentSourceValue = GetUrlKeyValue("Source", true, oldPostbackUrl);
            var newPostbackUrl = oldPostbackUrl.replace(currentSourceValue, "thank.aspx");

            if (!PreSaveItem()) return false;
            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newPostbackUrl, false, true));
        });

});

Monday, March 14, 2016

Add a button to ribbon in SharePoint 2013

SharePoint Designer 2013 can be used to create a ribbon button for SharePoint list or library. Once clicked, the button will perform a custom action function.

Step 1: In SharePoint Designer 2013, open the site containing the library or list where the custom action button on the ribbon will be deployed.

Step 2: Open the library or list from the left navigation panel.

Step 3: Create the custom action by clicking on “Custom Action” button from ribbon and select “View Ribbon.”

Step 4: Give the custom action a name and description.

Step 5: Select Navigate to URL and enter the URL for the action. This will redirect the user to the specified URL when the ribbon button is clicked. Then select the URL of the image to display on the ribbon button and click OK button.

Step 6: Open the site & then your list in your browser for which custom action button was created.

Step 7: Click on the “Files” tab in the ribbon. Locate the new custom action button.