cancel
Showing results for 
Search instead for 
Did you mean: 

Client side javascript action not working

bengrah
Champ on-the-rise
Champ on-the-rise
I've configured a new client-side javascript action in Share, but it doesn't seem to be firing my javascript when I click on the action. I'll go over the steps I've taken:

I've created a javascript called <em>mh.action.set-notification.js</em> that has the following code:


(function()
{
   YAHOO.Bubbling.fire("registerAction",
   {  
      actionName: "onMHActionSetNotification",
      fn: function onMHActionSetNotification(record)
      {
         //get node in question
         var nodeRef = new Alfresco.util.NodeRef(record.nodeRef);

         this.modules.actions.genericAction(
         {
            webscript: {
               name: "http://servername:8080/alfresco/service/mh/fn/notifications/set",
               method: "GET",
               queryString: "node=" + nodeRef.nodeRef
            },
            success: {
               message: "Notification added",
               fn: function onMHActionSetNotification_success() {
                  Alfresco.util.PopupManager.displayMessage({
                     text: "Notification set successfully",
                     displayTime: 4
                  })
               }
            },
            failure: {
               message: "Notification failed to add",
               fn: function onMHActionSetNotification_failure() {
                  Alfresco.util.PopupManager.displayMessage({
                     text: "Notification failure",
                     displayTime: 4
                  })
               }
            }
         });
      }
   });
});


I'm not getting any syntax errors on Chrome Developer console.

I've put this file into a JAR, the file resides in this structure <em>META-INF/components/documentlibrary/actions.</em> I've added the JAR into the classpath. I can confirm the JAR has been picked up and so has my JS, as I can browse to the file via the Sources tab in Chrome Dev Console.

In <em>share-config-custom.xml</em> I've added the following markup; I've added the JS as a dependency:


   <config evaluator="string-compare" condition="DocLibCustom">  
      <dependencies>  
         <js src="components/documentlibrary/actions/mh.action.set-notification.js" />
      </dependencies>
   </config>


I've then added a new document library action. Note: I'm using the same name for the function in the JS file "onMHActionSetNotification":


   <config evaluator="string-compare" condition="DocLibActions">
      <actions>
         <action id="miller-set-notifications" icon="miller-notifications-set" type="javascript" label="miller.actions.set-notification.doclib">
            <param name="function">onMHActionSetNotification</param>
         </action>
      </actions>
   </config>


I've bootstrapped <em>share-config-custom.xml</em> successfully, and I can see my new document action <em>Set Notification</em> is onscreen as it should.

When I click the action, nothing happens. I've tried putting breakpoints on the js and none of them are firing, it's as if the function isn't registered or something.

If someone could help me out that would be really appreciated.

Thank you,
ben.
1 REPLY 1

angelborroy
Community Manager Community Manager
Community Manager
How is implemented
miller-set-notifications
action on the repo side? It's required to be declared and implemented to have share action working.
Hyland Developer Evangelist