4

I want to call my javascript code in custom ribbon action in SharePoint online. I tried this code.

      <?xml version="1.0" encoding="utf-8"?>
      <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
        <CustomAction Id="6e661d80-ffa2-4460-b4d9-5b88cd1cbdf6.RibbonCustomAction1"
                      RegistrationType="List"
                      RegistrationId="{$ListId:Lists/Employee;}"
                      Location="CommandUI.Ribbon"
                      Sequence="10001"
                      Title="Invoke &apos;RibbonCustomAction1&apos; action">
          <CommandUIExtension>
            <CommandUIDefinitions>
              <CommandUIDefinition Location="Ribbon.ListItem.Actions.Controls._children">
                <Button Id="Ribbon.ListItem.Actions.RibbonCustomAction1Button"
                        Alt="Request RibbonCustomAction1"
                        Sequence="100"
                        Command="Invoke_RibbonCustomAction1ButtonRequest"
                        LabelText="Request RibbonCustomAction1"
                        TemplateAlias="o1"
                        Image32by32="_layouts/15/images/placeholder32x32.png"
                        Image16by16="_layouts/15/images/placeholder16x16.png" />
              </CommandUIDefinition>
            </CommandUIDefinitions>
            <CommandUIHandlers>
              <CommandUIHandler Command="Invoke_RibbonCustomAction1ButtonRequest"
                                CommandAction="javascript:alert('hii');"/>
            </CommandUIHandlers>
          </CommandUIExtension >
        </CustomAction>
      </Elements>

but while deploying this code give me error.I tried the same code in Sandbox solution and it is working fine.

enter image description here

Please let me know if any one of you also faced this issue

6
  • 1
    Copy/paste typo for the closing Elements missing the last > ? Other than that, maybe try another sequence number... the schema looks fine. I use javascript call like that in a custom action and it's working.
    – JayHell
    Apr 29, 2016 at 12:31
  • yes that is copy paste error.I tried by changing sequence number but still it does not worked.can you please place your code here.
    – Codec
    Apr 29, 2016 at 12:45
  • Try to put a different RegistrationId, put your list GUID hardcoded or 100 for custom list
    – JayHell
    Apr 29, 2016 at 12:53
  • sorry for late reply.I have tried by changing RegistrationId both by 100 for custom list and list GUID but still it is displaying same error
    – Codec
    May 2, 2016 at 4:07
  • What you are using? SharePoint App? May 2, 2016 at 9:07

1 Answer 1

3

Please follow the following approach.

  • Create a Sandbox solution rather then creating the SharePoint App
  • Deploy your solution to your SharePoint Online Solution Gallery
  • Activate your solution
  • Activate the feature of your newly activated solution

I know this is not the ultimate solution but this solution worked at my end.

Let me know whether it helped you or not.

1
  • 1
    Sandbox solutions are obsolete according to Microsoft
    – michalh
    Jun 29, 2018 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.