Oct 9, 2017

Check if current user is member of a SharePoint group using JQuery

Scenario
This code will help you to check if the current user is a member of a group.
Suppose you want to check if the current user is member of a Owners group or not. Just update the "grpName" variable value and run the code 😎
Steps to use the code
1. Use the Script Editor web part and add this code to check if a user is in a SP group 
2. Or use this code as a reference in a Content Editor web part
3. Use this script as a reference in a SharePoint custom list forms or in any SP pages
Code
$(document).ready(function (e) {

    ExecuteOrDelayUntilScriptLoaded(IsCurrentUserMemberOfGroup, "sp.js");
});

function IsCurrentUserMemberOfGroup() {
    var grpName = "Site Owners";
    var userInGroup;
    var currentContext = new SP.ClientContext.get_current();
    var currentWeb = currentContext.get_web();

    var currentUser = currentContext.get_web().get_currentUser();
    currentContext.load(currentUser);

    var allGroups = currentWeb.get_siteGroups();
    currentContext.load(allGroups);

    var group = allGroups.getByName(grpName);
    currentContext.load(group);

    var groupUsers = group.get_users();
    currentContext.load(groupUsers);

    currentContext.executeQueryAsync(OnSuccess, OnFailure);

    function OnSuccess(sender, args) {

        var groupUserEnumerator = groupUsers.getEnumerator();
        while (groupUserEnumerator.moveNext()) {
            var groupUser = groupUserEnumerator.get_current();
            if (groupUser.get_id() == currentUser.get_id()) {
                userInGroup = true;
                break;
            }
        }
        if (userInGroup) {
            //alert("user exists in the group");
            //do some operation.
        }

        else {
            //alert("user doestn't exist in the group");
        }

    }

    function OnFailure(sender, args) {
        //error message.
    }
}
Happy coding!!!

Oct 4, 2017

Differences between Communication Sites and Modern Team Sites


#
Communication Sites
Modern Team Sites
 1
Communication Sites are a convenient way for broadcasting or communicating information to wider audience  
Team Sites are sites created for users to work collaborate as a team
 2
In Communication site, typically there are a small number of users and many readers
In a team site, most users contribute content and collaborate each other
 3
There are 3 designs (Topic, Showcase and Blank) available for Communication Sites to choose from while site creation
There are no different designs available for Team sites to choose from while site creation
 4
Communication Site are ready made from the get go for sharing information 
 Team sites are focused on Collaboration and backed by Office 365 Groups
 5
No shared apps are created automatically when communication site is created
 A shared Documents, Calendar, One Note, Planner tasks board, mailbox is created automatically when a new modern team site is created
 6
Office 365 groups are not automatically when communication site is created
Creating a Team Site automatically creates Office 365 groups
 7
Communication Sites are private by default 
Modern Team Sites are public by default
 8
While site creation, it does not prompt to add users/members to the site
While site creation, it automatically prompts to add additional owners, members
 9
Default top navigation (Home, Documents, Pages and Site Contents) is added when new site is created 
There is no default top navigation
 10
There is no left navigation in home page 
Traditional left navigation is created by default
 11
Clicking on “Home” in the top menu just navigates to the home page instead of displaying more options
 Clicking on “Site Name” link opens a small context menu showing options to navigate to Home, Conversations, Calendar, Files, Notebook, Planner and Members. Also, it shows the numbers of members, option to leave group
 12
There are no such options in Communication Sites
Team Sites show a summary of team members and a link to team conversations in the upper right-hand corner of the site navigation
 13
The security groups are the more traditional SharePoint groups
It is Office 365 groups for permissions in modern team sites

See Also
Communication Sites in SharePoint Online
Modern Team Sites in SharePoint Online Explained

Please free to comment. Always. your comments help me to write more.😃 Share this post to others if this helps you!😇
Don't forget to subscribe to the posts to get notified about new tutorials by clicking the Subscribe button on the top right corner and follow us in social buttons as well.

Oct 2, 2017

Modern Team Sites in SharePoint Online Explained

Modern Team sites are Team Sites integrated with Office 365 groups and it provides options to collaborate better than before
When you create a modern team site in SharePoint Online, it automatically creates the O365 group, group email address, and ability to identify whether this site will contain sensitive data (privacy) and more new features.
The home page of a SharePoint Online modern team site gives you immediate visibility into site activity and important documents, with quick access to Office 365 Groups, its members and associated Office 365 apps.


Also, Modern Team Sites works seamless in Mobile apps as well. This way it increases the usability of SharePoint, collaborate on the go!!
DOWNLOAD this eBOOK from this link
See Also


This eBook has detailed information of each features of Modern Team Sites in SharePoint Online.
Your feedback, ratings are welcome!!