If somebody like the post and its helpful in your work then, add comments.
Showing posts with label Office 365 SharePoint. Show all posts
Showing posts with label Office 365 SharePoint. Show all posts

Friday, May 22, 2015

SharePoint ECMA : Get pages library items in ECMA

To get the pages library items,  using the JavaScript/JSOM. For that in the clientContext.load we have to pass "File" parameter and than the site columns(internal names)

getNewsPages = function() {
                 var clientContext = new SP.ClientContext.get_current();
                var oList = clientContext.get_web().get_lists().getByTitle('Pages');
                var camlQuery = new SP.CamlQuery();
                camlQuery.set_viewXml(" 50");
                selectedDoc = oList.getItems(camlQuery);
                clientContext.load(selectedDoc , 'Include(Id, Title,File,PublishedDate1,TeaserText,TeaserImage,FileRef,NewsFilter)');
                clientContext.executeQueryAsync(gettingNewsPagesSuccess , onQueryFailed);

            },
            gettingNewsPagesSuccess = function() {
                var listItemEnumerator = selectedDoc.getEnumerator();
                while (listItemEnumerator.moveNext()) {
                    var oListItem = listItemEnumerator.get_current();
                    tempList.push({
                        "Id": oListItem.get_id(),
                        "Title": oListItem.get_item('Title') ,
                        "PublishedDate": oListItem.get_item('PublishedDate1'),
                        "TeaserText": oListItem.get_item('TeaserText') ,
                        "TeaserImage": oListItem.get_item('TeaserImage'),
                        "Path": oListItem.get_item('FileRef'),
                        "NewsFilter": oListItem.get_item('NewsFilter')
                    });
                }

            },

Monday, March 2, 2015

Office 365 : Create a site using custom site template

To create a site using your designed custom site template in JSOM/ECMA, we can use below example :

 createProjectSite = function ($data) {
            dialogValue = SP.UI.ModalDialog.showWaitScreenWithNoClose("Site Creation", "Working on it...", 120, 400);
            id($data.Id);
            var url = $data.Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
            currentProjectObject = $data;
            var clientContext = CORO.megaMenucontext;
   


            var WCI = new SP.WebCreationInformation();
            WCI.set_webTemplate('{a5269682-aec6-49d7-b3f5-7481039abff8}#ProjectTemplate');
            WCI.set_description($data.ProjectDescription);
            WCI.set_title($data.Title);
            WCI.set_url(url);
            WCI.set_language('1033');
            if ($data.Access == "Public") { WCI.set_useSamePermissionsAsParentSite(true); }//To inherit the permission
            if ($data.Access == "Closed") { WCI.set_useSamePermissionsAsParentSite(false); }//To break the permission
            newWeb = projectWeb.get_webs().add(WCI);
            //save changes and generate callbacks
            clientContext.load(projectWeb);
            clientContext.executeQueryAsync(onCreationSuccess, onQueryFailed);
        },

Friday, August 1, 2014

Yammer : How to get current logged in user unseen message count

Well this is my first application of Yammer, I was wondering how to start on the application. So, first thing come in my mind that to explore the Yammer,

What is yammer?

How can we use it?

What are the entities in yammer, which we can use or integrate in our application. etc

So, logged in Yammer, created network added the people. So, now when all thing are up then for just creating a sample application a scenario occurs in my mind “current logged in user unseen message count”. How to start on the, where to deploy that????

I added one more Technology my FAV one, SharePoint. Final scenario showing  current logged in user unseen message count in SharePoint online. Created a trial account in that and create on page. First I tried with yammer default feed JS code. It works find ….OK.

So, for custom development I looked on Google and found the wonderful description on yammer API. How to consume in various domains, how add in various platforms. Link is below

https://developer.yammer.com/connect/

To get current logged in user unseen message count

<h1><b>Yammer</b></h1> 
    <h3 > Unseeen Messages</h3><div id="numberOfMessages"></div>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" data-app-id="[Your App ID]" src="https://assets.yammer.com/assets/platform_js_sdk.js"></script>
 

    <span id="yammer-login"></span>
   
    <script type="text/javascript" >
        yam.getLoginStatus(
      function(response) {
        if (response.authResponse) {
              console.log("logged in");            
               yam.platform.request({
                url: "networks/current.json",
                method: "GET",       
                beforeSend: function (req) { //print message response information to the console
                    yam.platform.setAuthToken(response.access_token);
                } ,
               
                success: function (user) { //print message response information to the console
                    document.getElementById('numberOfMessages').innerHTML= user[0].unseen_message_count;
                },
                error: function (user) {
                  alert("There was an error with the request.");
                }
              });

        }     
      }
    );
    </script>

but before adding the above code we have to create on app in yammer

image

image

image

remember this redirect URL should be match with your domain and JavaScript origin will be the URL of page where the JS or JS is rendering.

Click Save

image

This big bold highlighted one is the key point where I stuck an have goggling for like 2 days Smile

image

image