Search This Blog

Wednesday, October 14, 2015

How to acces sharepoint 2013 user profile using C#

UserProfile profile;
SPServiceContext serviceContext = SPServiceContext.GetContext(SPContext.Current.Site);
string fromMail = string.Empty;

public void getEmailID()
{
    try
    {
        UserProfileManager upm = new UserProfileManager(serviceContext);
        profile = upm.GetUserProfile(currentUser.LoginName);
        if (profile != null)
         {
             if (!string.IsNullOrEmpty(Convert.ToString(profile[PropertyConstants.WorkEmail].Value)))
              {
                    fromMail = profile[PropertyConstants.WorkEmail].Value.ToString();            
              }
         }
    }
    catch (Exception ex)
    {
       throw;    
    }
 }

Using this UserProfileManger we can access all the details stored for a sharepoint user in User Profile Service Application.

thanks,

Tuesday, September 1, 2015

Get Values From Query String Using jQuery

 $(document).ready(function () {
            try {              
                var mode = GetParameterValues('Mode');
                alert(mode);
            } catch (e) {
                alert(e);
            }
        });

function GetParameterValues(param) {
            var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < url.length; i++) {
                var urlparam = url[i].split('=');
                if (urlparam[0] == param) {
                    return urlparam[1];
                }
            }
        }

Friday, August 7, 2015

The feature failed to activate because a list at 'PublishingImages' already exists in this site. Delete or rename the list and try activating the feature again.


The most common issue we may face when we try to activate SharePoint Publishing infrastructure Feature from Manage site features.

Try to activate that feature using Shell command. It will work out with out error:

 Enable-SPFeature -Identity PublishingWeb -URL http://test:1000/ -Force

thank you,

Monday, August 3, 2015

Adding User Permissions using Power shell script in SharePoint 2013


In SharePoint we are having permission level operations. To that SharePoint group we can add users through Site Settings -> Site Permissions.

And also we can give permissions using PowerShell scripts.

For Single User:

new-spuser -UserAlias "User1" -Web "http://test:100/sites/home1" -Group "TestUsers"

For Every One:

new-spuser -UserAlias "Everyone" -Web "http://test:100/sites/home1" -Group "TestUsers"

By executing this PowerShell script we can add users to the SharePoint groups.


thank you,

Friday, July 17, 2015

Change the "SharePoint" text in the top left corner


$webApp = Get-SPWebApplication http://tozit-sp:2015
$webApp.SuiteBarBrandingElementHtml = "New Text Here"
$webApp.Update()

Thursday, July 16, 2015

How to enable and disable Quick launch in SharePoint 2013


To display the Quick Launch menu using the SharePoint 2010 web interface, follow these steps:
  1. Navigate to Site Actions, Site Settings, Tree View (under Look and Feel).
  2. Select the Enable Quick Launch check box and click OK

This will enable and disable the quick launch.

View all Webparts on your SharePoint Page

All you need to do is add this string to the end of your URL "?contents=1" on any of your SharePoint Pages

Restricting Custom People Picker to only one Sharepoint group programatically

Refer the following script files in your page,     <!-- For People Picker -->     <script type="text/javascript" src...