8 Replies Latest reply on Sep 9, 2015 9:48 PM by spoorthy

    Get Current ContentID in App

    spoorthy

      Hi all,

       

      Pawan Shah

       

      I have an app whose action path is set to contents,so that I need to get that current content Id.

       

      osapi.jive.core.container.getLaunchContext(function (selection) {

      });

       

      But here the result selection is returning null.

      Could anyone help me on this?

       

      Thanks,

      Spoorthy

        • Re: Get Current ContentID in App
          pawans

          In this case just add this code when you initialise the app

           

          gadgets.actions.updateAction({

              id:"org.jivesoftware.movecontent.group",

              callback:function(selection){

                    console.log(selection);

               }

          )

           

          where the id is the one you mention in app.xml similar to this --> move-content-app/app.xml at master · shahpawan/move-content-app · GitHub

           

          The one you have used works if your app is in places tab like my apps at the link above.

          1 person found this helpful
            • Re: Get Current ContentID in App
              spoorthy

              Thanks pawan,

               

              Iam developing my custom app so can i give this id:"org.jivesoftware.movecontent.group",

               

              My app action path is

              <action id="com.jivesoftware.contentaction"

                                      path="jive/actions/content/*"

                                      label="Translator"

                                      view="createview"

                                      windowSpec="left=80,top=80,width=1000,height=1000,toolbar=1,resizable=0"/>

              when i click onthat app link i want to get that respective contentID.

               

              Iam trying this but returning null----

               

              gadgets.util.registerOnLoadHandler(function () {   

                      osapi.jive.core.container.getLaunchContext(function (selection) {

                               var type = selection.jive.content.type; 

                                \var contentid = selection.jive.content.id

                      });

              });

              • Re: Get Current ContentID in App
                spoorthy

                gadgets.util.registerOnLoadHandler(function () { 

                    console.log('Hello World!'); 

                  gadgets.actions.updateAction({ 

                  id: "com.jivesoftware.contentaction",

                  callback: function (selection) { 

                  console.log("selection:"+ selection); 

                  console.log(JSON.stringify(selection));

                  var type = selection.jive.content.type; 

                  var contentid = selection.jive.content.id;

                  console.log(type);

                  console.log(contentid); 

                  }         

                  }); 

                });

                returing type:""

                id=-1

              • Re: Get Current ContentID in App
                pawans

                Hi,

                I just created a new app using jive-sdk create app and tried a short code.

                Check this attached zip which has the small app.

                This is the app represented in app.xml -->

                <action id="com.jivesoftware.awesome"
                  path="jive/actions/content/*"
                  label="Awesome App"
                  view="canvas"
                />
                

                 

                 

                And here is a simpler JS code -->

                 

                $(document).ready(function(){
                    gadgets.actions.updateAction({
                            id:"com.jivesoftware.awesome",
                            callback:function(selection){
                                console.log(selection);
                            }
                        }
                    )
                });
                

                 

                 

                I have purposely used $(document).ready instead of  gadgets.register.... to show the minimal jive code required to achieve this.

                Here's the result I get in console

                 

                Screen Shot 2015-09-09 at 1.16.39 pm.png

                 

                You can get document data using this id and document type 102 in REST this way -->

                https://jiveurl/api/core/v3/contents?filter=entityDescriptor(102,1843)
                
                1 person found this helpful