1

I have two ribbon buttons:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="CustomCustomRibbonTab"
Location="CommandUI.Ribbon"
RegistrationId="0x01"
RegistrationType="ContentType"
Sequence="100"
>

<CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition
      Location="Ribbon.Tabs._children">
      <Tab
        Id="Ribbon.CustomRibbonTab"
        Title="Cotizaciones"
        Description="Manejo de cotizaciones"
        Sequence="501">
        <Scaling
          Id="Ribbon.CustomRibbonTab.Scaling">
          <MaxSize
            Id="Ribbon.CustomRibbonTab.MaxSize"
            GroupId="Ribbon.CustomRibbonTab.ManageCustomGroup"
            Size="OneLargeTwoMedium"/>
          <Scale
            Id="Ribbon.CustomRibbonTab.Scaling.CustomTabScaling"
            GroupId="Ribbon.CustomRibbonTab.ManageCustomGroup"
            Size="OneLargeTwoMedium" />
        </Scaling>
        <Groups Id="Ribbon.CustomRibbonTab.Groups">
          <Group
            Id="Ribbon.CustomRibbonTab.ManageCustomGroup"
            Description="Aceptación o rechazo de cotizaciones enviadas"
            Title="Manejo de cotizaciones"
            Sequence="52"
            Template="Ribbon.Templates.CustomTemplate">
            <Controls Id="Ribbon.CustomRibbonTab.ManageCustomGroup.Controls">
              <Button
                Id="Ribbon.CustomRibbonTab.ManageCustomGroup.Accept"
                Command="CustomRibbonTab.AprobarCotizacionCommand"
                Sequence="15"
                Image32by32="/_layouts/images/monitor_go.png"
                Description="Cotizaciones aprobadas"
                LabelText="Aprobar cotizaciones seleccionadas"
                TemplateAlias="AC" />
              <Button
               Id="Ribbon.CustomRibbonTab.ManageCustomGroup.Copy"
               Command="CustomRibbonTab.RechazarCotizacionCommand"
               Sequence="19"
               Image32by32="/_layouts/images/monitor_delete.png"
               Description="Negar cotizaciones seleccionadas"
               LabelText="Rechazar cotizaciones seleccionadas"
               TemplateAlias="RC"/>
            </Controls>
          </Group>
        </Groups>
      </Tab>
    </CommandUIDefinition>
    <CommandUIDefinition Location="Ribbon.Templates._children">
      <GroupTemplate Id="Ribbon.Templates.CustomTemplate">
        <Layout
          Title="OneLargeTwoMedium"
          LayoutTitle="OneLargeTwoMedium">
          <Section Alignment="Top" Type="OneRow">
            <Row>
              <ControlRef DisplayMode="Large" TemplateAlias="AC" />
            </Row>
          </Section>
          <Section Alignment="Top" Type="OneRow">
            <Row>
              <ControlRef DisplayMode="Large" TemplateAlias="RC" />
            </Row>
          </Section>
        </Layout>
      </GroupTemplate>
    </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers>
    <CommandUIHandler
      Command="CustomRibbonTab.AprobarCotizacionCommand"
      CommandAction="javascript:MarkItemsFinished();"/>
    <CommandUIHandler
      Command ="CustomRibbonTab.RechazarCotizacionCommand"
      CommandAction="javascript:alert('Cotización rechazada');"/>
  </CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
  <CustomAction Id="CustomRibbonTab.AprobarCotizacionCommand.Script"
            Location="ScriptLink"
            ScriptSrc="/_layouts/js/Cuenta.js"/>
</Elements>

And have a js file named Cuenta.js, but when I click the first button nothing happens. I checked the name method on js file and is correct. The CustomAction near the end is not taking any of the methods of the js. What can I do about it?. Thank you very much.

3
  • are you using sharepoint 2013 or 2010? Commented Feb 20, 2016 at 9:18
  • Sharepoint 2010 Commented Feb 20, 2016 at 17:53
  • okay, give a try to suggestion answered below by me Commented Feb 21, 2016 at 5:55

1 Answer 1

1

If you are using SharePoint 2013, you need to use this url to reference layout:

/_layouts/15/ProjectFolderName/JavaScriptFileName.js

<CustomAction Id="CustomRibbonTab.AprobarCotizacionCommand.Script"
            Location="ScriptLink"
            ScriptSrc="/_layouts/15/ProjectFolderName/js/Cuenta.js"/>

If you are using SharePoint 2010, you need to use:

<CustomAction Id="CustomRibbonTab.AprobarCotizacionCommand.Script"
                Location="ScriptLink"
                ScriptSrc="/_layouts/ProjectFolderName/js/Cuenta.js"/>
3
  • Thanks for your answer. In sharepoint 2010 do I need to add "14" on ScriptSrc line? like this: ScriptSrc="/_layouts/14/ProjectFolderName/js/Cuenta.js"/> Thanks again Commented Feb 22, 2016 at 3:26
  • no, you don't need to add "14" Commented Feb 22, 2016 at 10:43
  • This is key when using a custom ribbon action. Under 2016 a solution will deploy to the /16 hive but a 2016 farm will generally point to the /14 hive (for some things). So the /15 redirect will take you to the /16 hive where things get deployed. Welcome to the mess that is Microsoft.
    – Bil Simser
    Commented May 4, 2017 at 16:31

Your Answer

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

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