Tuesday, 2 September 2014

Adding user in SharePoint group programmatically

Below is the code to add user in SharePoint group programmatically:


 using (SPSite site = new SPSite(Respective Site URL))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    try
                    {
                        SPUser requiredUser = web.EnsureUser("domainname\\username");

                        if (requiredUser != null)
                        {
                            SPGroup requiredGroup = web.Groups["groupName"];
                            if (requiredGroup != null)
                                requiredGroup.AddUser(requiredUser);
                        }
                   
                    }
                    catch (Exception ex)
                    {
                     
                    }                 
                }
            }

Monday, 1 September 2014

Error occurred in deployment step 'Retract Solution': Object reference not set to an instance of an object.

Today while deploying a custom solution on our development server using Visual Studio 2012, I received below error in Visual Studio: 
"Error occurred in deployment step 'Retract Solution': Object reference not set to an instance of an object."

This was working well till day before and suddenly it started to throw same error again and again.
Then I went to retract same solution through Central Administration, and it shown me actual error that was happening.

The SharePoint_Config log file got full. After shrinking the log file, solution got deployed without any error.

Thursday, 21 August 2014

How to check which edition of SharePoint is running on server?

You can check the SharePoint Edition by going into Central Administration.

In Central Administration go to Upgrade and Migration --> Convert farm license type.
It will show you current edition. For e.g. SharePoint Server with Enterprise Client Access License.

Hope this helps.!!!!!


Tuesday, 3 June 2014

SharePoint: This entry cannot be validated. Exception Object reference not set to an instance of object. occurred

Today while using Audience settings in navigation , I got the error while validating groups in Audience setting, even groups are correctly set.

The following error message was appearing during audience validation:
 This entry cannot be validated. Exception Object reference not set to an instance of object. occurred

After some quick search on internet i found that, there might be possibility of User Profile Service is not associated with web application.

To check that, I went to Central Administration --> Application Management --> Manage Web application.
Selected my web application and clicked on "Services Connection"

The check-box in front of User Profile Service Application was unchecked. I selected the check-box and clicked OK.

Then I went to set the audience and problem was resolved.

Cheers!!!!!!. Hope this helps.



Thursday, 4 July 2013

Prevent duplicate values in SharePoint 2007 list column

In SharePoint 2007 list, if we want to prevent duplicate values in a column, we can make use of the SPServices MakeUnque function.

More details are here:
http://spservices.codeplex.com/wikipage?title=$%28%29.SPServices.SPRequireUnique&referringTitle=Documentation

Currently, the function works only with Single line of textcolumns.





Friday, 28 June 2013

Cannot perform this operation. The file is no longer checked out or has been deleted - SharePoint Designer 2013

While working in SharePoint Designer 2013, sometime it demanded to check out files that are not checked in, refused to check in other files. And it shows below error message:

Cannot perform this operation. The file is no longer checked out or has been deleted

After some search on google, I found this post, which helped a lot.

We need to clear the cache of sharepoint designer. The cache is composed of these 2 folders:
  • %APPDATA%\Microsoft\Web Server Extensions\Cache
  • %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache
Just delete their contents and you are done.


Related Posts Plugin for WordPress, Blogger...