1 Reply Latest reply on Apr 29, 2015 8:09 AM by nilsheuer

    Getting current content from app action

    jzawadzk

      Hi all,

       

      We're trying to create an app that will display an action for documents on the side panel and access this content's external properties(and then do some work with them). I couldn't find a way of getting the id of content that the user is viewing.

       

      Following the suggestion posted in OSAPI Api - retrieve current "place"? I've tried:

      gadgets.util.registerOnLoadHandler(function() {
          osapi.jive.core.container.getLaunchContext(function (selection) {
              console.log(selection);
          });
      });
      
      
      

      but the console keeps outputting null.

       

      Interestingly enough the above worked in Using a Hidden App in Your Jive Community but failed to return anything when invoked through:

      <![CDATA[
        <action id="com.jivesoftware.contentaction"
            path="jive/actions/content/document"
            label="My action"
            view="main"/>
      ]]>
      
      
      

       

      Also, using:

      osapi.jive.corev3.people.getViewer().execute( function(viewer) {
          console.log(viewer);
      });
      
      
      

      prints out the correct user in both cases.

       

      I looked around for other solutions, but was unable to find any. This problem is currently holding us up on some important work we're doing, hence this case.

       

      Thanks,

      Jakub

       

      joelee Alistair Antoine

        • Re: Getting current content from app action

          For app actions (and embedded experiences, too IIRC) you need to use update actions

          In your registeronloadhandler

           

              gadgets.actions.updateAction({
                  id: "net.pokeshot.flowworker.remindme", //the id you specified in the app.xml
                  callback: init
              });
          
          and then get the current context in your callback function
              init = function (selection) {
                  console.log("selection:", selection);
              
                    //This returns a v2 type object, so you should convert it to a api v3 object using the context resolver
                  var myContext = osapi.jive.corev3.resolveContext(selection, function (context) {
                      console.log(context);
                
                  });
          
              }
          
          

           

          It would be nice if this could be cleared up to be consistent, eventually

          1 person found this helpful