Thursday, December 24, 2015

How do I quickly resolve namespaces in Visual Studio 2015

Most us new to Visual Studio 2015. We can't able to get To Resolve option while entering missed namespace. Here is the tips to get Resolve option.




Right click the red marked code. Then Choose Quick Actions... Choose the namespace you want to add.


Thursday, October 15, 2015

Assign title automatically for Document Library

Introduction

As we all know about Document Libraries in SharePoint. We have a drag and drop option in SharePoint 2013 libraries. The thing is, SharePoint doesn't give an option to enter title while uploading. We need to go Edit Property screen to enter title. So, here i am going to provide a SP workflow to assign title automatically while uploading. 

SP Workflow

Here is the steps to assign the title.

  • Open your site in SharePoint Designer
  • Add a new list workflow, choose your document library in the drop down list 
  • Then, Workflow editor will open with Step1

  • Click Condition at ribbon
  • Choose If any values equal value
  • Then, Change value with Current Item: Title is Empty
  • Click Action to set value
  • Set Title to Current Item:Name
  • Result will be



Wednesday, October 14, 2015

Unexpected error on server associating the workflow

Some of us might be faced this issue while publishing the workflow from SharePoint designer. To resolve this, need to extend the UserDefinedWorkflowMaximumComplexity limit for the web application.

Run the following script in your farm

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 

$new_limit = 10000;

$web = Get-SPWebApplication "your web application URL"

$web.UserDefinedWorkflowMaximumComplexity = $new_limit 


$web.Update()

SharePoint list report creation using SSRS

Introduction

I am going to share an idea about creating SSRS report with SharePoint List. First create a base list in SharePoint site. Here is the steps to create a report

SSRS 

Open your report builder. We will get start up dialog box which is having an options like New Report, New Dataset, Open and Recent. 


Then, Click Chart Wizard under New Report. First we need to create dataset which is going to provide data to chart. Choose Create a dataset and click Next


Choose the connection data source. We have to connect source of data. Here we are going to connect SharePoint list as source. 


Click New. Then we may get Data Source Properties window. Give name for the Data Source. Choose SharePoint List in Connection Type. Give SharePoint site URL in Connection strin box. Click Test Connection for the confirmation of connection.Then, Click Ok


Published Data Source will be displayed once connection established. 


If we want edit the connection we have an option in this window. Click Next if there is no change in data source.

Next, We will get Design a query window. Here we can choose the list from data source. we have an option to filter at right side.

I have chose Discussion List to get chart. Then Click Next. 

Next window is used to choose the chart type. Chart types are Column, Line, Pie, Bar and Area. I have chose Column chart type.
Click Next

Arrange chart fields window is displaying now. Here we need to choose the field for create chart


We will land to Chart style window once we clicked Next. Here we can choose defined style for chart

Click Finish.

Now we were landed to Chart Editor screen. Here we can able to edit Chart Properties.


Click Run at top ribbon. Chart will display in Run window.

Tuesday, October 13, 2015

server could not complete your request sharepoint designer

Most of us came across this issue while open the site using SharePoint Designer. 


Do following steps to resolve this,

  • Goto IIS
  • Check SharePoint Web Services site's authentication
  • Enable Anonymous Authentication


Wednesday, September 23, 2015

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.

We may get "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again." issue when try to BreakRoleInheritance  of list programmatically. To resolve this, Add AllowUnsafeUpdates = true.

For Example,

web.AllowUnsafeUpdates = true;

Make it false once BreakRoleInheritance is over.


Monday, September 21, 2015

Export all events to iCal format programmatically


We all know about iCal format which is used to import the Calendar items to Outlook. We can able to export a single item to iCal using OOTB. But we doesn't have the option to get all the events in single .ics file. Here i am going to provide a code base to export all the events as .ics format

 StringBuilder sw = new StringBuilder();
                sw.AppendLine("BEGIN:VCALENDAR");
                sw.AppendLine("VERSION:2.0");
                sw.AppendLine("METHOD:PUBLISH");
                foreach (var item in items)
                {

                    sw.AppendLine("BEGIN:VEVENT");
                    sw.AppendLine("CLASS:PUBLIC");
                    sw.AppendLine(string.Format("CREATED:{0:yyyyMMddTHHmmss}", DateTime.UtcNow));
                    sw.AppendLine("DESCRIPTION: " + Convert.Tostring(item["Description"]));
                    sw.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmss}", Convert.ToDateTime(item[EndDate]));
                    sw.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmss}", Convert.ToDateTime(item[StartDate]));
                    sw.AppendLine("SEQUENCE:0");
                    sw.AppendLine("UID:" + Guid.NewGuid().ToString());
                    sw.AppendLine("LOCATION:" + Convert.ToString(item["Location"]));
                    sw.AppendLine("SUMMARY;LANGUAGE=en-us:" + Convert.ToString(item["Title"]));
                    sw.AppendLine("END:VEVENT");
                }
                sw.AppendLine("END:VCALENDAR");

                Page.Response.Clear();
                Page.Response.ContentType = "text/calendar";
                Page.Response.AddHeader("content-disposition", "inline; filename=" + "Test.ics");
                Page.Response.Write(sw.ToString());
                Page.Response.Flush();

Put the above code base in your webpart. Then iCal format will work like an awesome.

Thursday, September 17, 2015

Unable to cast object of type to'Microsoft.SharePoint.WebPartPages.WebPart'

Some of us face this issue while casting webparts in the page. Your code is like this when you get this error.

foreach (Microsoft.SharePoint.WebPartPages.WebPart item in wpManager.WebParts)
            {
                if (item.Title.Equals(webpartTitle))
                {
                    isExists = true;
                }

            }

Make like this

foreach (System.Web.UI.WebControls.WebParts.WebPart item in wpManager.WebParts)
            {
                if (item.Title.Equals(webpartTitle))
                {
                    isExists = true;
                }

            }

Monday, September 14, 2015

Export Taxonomy Terms to SharePoint List


SharePoint give an option to have store metadata information. That's called Taxonomy. It's common place to have terms. Now i am going to give a script to export this terms to list.

Script

$site = Read-Host "Enter  Site URL :"
$web = Read-Host "Enter Sub Site URL :"
$spweb= Get-SPWeb $web
$country = $spweb.Lists["Your List Name"]

$termSet = Get-SPTaxonomySession -Site $site
$termStore = $termSet.TermStores[0]
$termGroup = $termStore.Groups[“TermGroupName”]
$termStore = $termStore.Name
foreach ($termGroups in $termGroup.TermSets)
{
    foreach ($termSets in $termGroups.Terms)
    {
        $newItem = $country.items.add()
        $newItem["Title"] = $termSets.Name
        $newItem.Update()
        Write-Host $termSets.Name " has been added !!!" -ForegroundColor Green
    }
}

That's all. Terms will be added in the list

Tuesday, September 8, 2015

Updating Calendar Overlay using Powershell

Introduction

SharePoint having an option for Calendar overlay. Click here to have introduction. Now, I am going to share a script to update it.

Calendar Settings

Once we applied the Calendar Overlay to the list. The Calendar Settings get append with AggregationCalendar. 


We need to modify this Aggregation Calendar for changes we want in Calendar Overlay. This Calendar Settings is a string. So we can do replace string with old string using script. For example, If we want to change the color. Script will be like this,

$web = Read-Host "Enter Site URL :"
$spweb= Get-SPWeb $web
$calendar = $spweb.Lists["Your List Name"]
$calendar.DefaultView.CalendarSettings = $calendar.DefaultView.CalendarSettings.Replace("Color=""3""","Color=""2""")
$calendar.DefaultView.Update()

That's all Calendar Settings has been updated

Wednesday, September 2, 2015

Select lookup field in NewForm.aspx using Querystring


We all knew about lookup column in SharePoint. It is used to get reference from another list. Here, I am going to give an idea to select this lookup column in New form using querystring.

Pass your querystring to Newform.aspx like

http://yourmachinename:portnumber/lists/listname/newform.aspx?itemId=1

Insert a content editor in list's new form. Paste the below script in content editor
<script>
$(document).ready(function ($) {
function SetFormFields() {
    
    var QItemID = GetQueryStringParameter("itemId", "NULL");
    var IDLookup = SPUtility.GetSPFieldByInternalName('yourcolumnname');
    if (QItemID != "NULL") {
        IDLookup.SetValue(QItemID);
    }    
}
});

function GetQueryStringParameter(key, default_) {
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null)
        return default_;
    else
        return qs[1];
}
</script>

Tuesday, August 25, 2015

Adding column in existing XLSTListViewwebpart in Powershell

SharePoint provides an option to show particular list view in another pages. We can able to show this using xsltlistviewwebpart. Most us met a situation to modify the listview after placed this in page. Here, i am going to provide a powershell script for this.

$web = Read-Host "Enter site URL : "

$spweb= Get-SPWeb $web


$list = $spweb.Lists["Your List Name"]
$field = $list.Fields["Column Name"]

$displayPage = $spweb.GetFile("SitePages/Home.aspx");
$wpManager = $spweb.GetLimitedWebPartManager($displayPage,[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

foreach($webpart in $wpManager.WebParts)

{
 if($webpart.Title -eq "Your webpart title")
    {
        Write-Host "Updating view" -ForegroundColor Magenta
        $lvwebpart = [Microsoft.SharePoint.WebPartPages.XsltListViewWebPart]$webpart
        $lvwebpart.View.ViewFields.Add($field)

        $lvwebpart.View.Update();
        Write-Host "view has been updated" -ForegroundColor Green
    }
}

Monday, August 24, 2015

Show each of these additional fields for Lookup Column in Powershell

SharePoint having an option to get a reference from another list using Lookup column. We can also able to pull some additional column values from the list. We can do this manually while editing the lookup column.


Here, I am going to give a powershell script to enable this

$web = Read-Host "Enter site URL : "
$spweb= Get-SPWeb $web

$listParent = $spweb.Lists["Parent List Name"]
$listChild = $spweb.Lists["Child List Name"]

Write-Host "Applying AddDependentLookup" -ForegroundColor Magenta
#Getting lookup column from child list
$lookupField = $listChild.Fields["LookupField"]
$newField= $listChild.Fields.AddDependentLookup("New Column Name",$lookupField .Id)
$secondary = $listChild.Fields.GetFieldByInternalName($newField)
$secondary.LookupField = $listParent.Fields["New Column Name"].InternalName
$secondary.update()
Write-Host "Applied AddDependentLookup" -ForegroundColor Green 

Tuesday, August 11, 2015

Removing Event Receiver from SharePoint list

Introduction

As we know about event receiver in SharePoint. I am going to share a powershell script which is used to remove an associated Event Receiver

Script 

function RemovingEventReceiver($siteURL ,$listName, $eName)
{
$spweb= Get-SPWeb $siteURL
$list = $spweb.Lists[$listName]

 $noe = $list.EventReceivers.Count

  if ($noe -gt 0)
{
   for( $index = $noe -1; $index -gt -1; $index–-)
   {
      $receiver = $list.EventReceivers[$index] ;
      $name = $receiver.Name
      $typ = $receiver.Type ;
 
      if ($name -eq $eName)  
      {
         $receiver.Delete()
         Write-Host "Event receiver " $name " is deleted from " $listName -ForegroundColor Green
      }
   }
}
}
$web = Read-Host "Enter site URL : "

RemovingEventReceiver $web "YourListName" "EventReceiverName"

Tuesday, August 4, 2015

Color code for Calendar item using Calendar Overlay

Introduction

Some of us tried to make color code for events based on their category. Here i am going to give an idea to achieve this using calendar overlay.

Calendar Overlay

At First, We need to create Calendar list. Then, Create category based views in the list. For example, If we want display the holiday with different color. First we need to create view with holiday category based filter.

Creating View

Do following steps to create category based view
  • Click List Settings
  • Click Create View
  • Select Calendar View
  • Give view name and set filter for category field 
  • Clock OK

Set Calendar Overlay

Here is the steps to set overlay
  • Click Calendar Overlay in ribbon
  • Click New Calendar
  • Give Name of the calendar
  • Choose SharePoint as type of calendar
  • Select the color from dropdown
  • Give view URL as web url of calendar
  • And choose List and List view from dropdown list. Then click OK
Calendar overlay is all set. Now put data with holiday category. We can see the item with purple color code.
Note: There is a duplication in above view. To avoid this set Filter in Calendar view with Category equal to null. Then duplication problem will be solved.




Monday, August 3, 2015

MySite in SharePoint 2013

Introduction

We are going to see about mysite in SharePoint. SharePoint has introduced many feature in it. Let us see one by one.

Features in MySite

MySite is a personal site or individual users of an organization. By default we are having NewsFeed, OneDrive and Sites at top of every page. 


Mysite give users social networking and collaboration features. User can share their interests, projects and useful information.

NewsFeed

Its a default page of mysite. NewsFeed is a social hub where user can see the updates from people, documents, sites and tags. This page will display the recent activities of user's specified colleagues and their interests. The newsfeed page will display the followings,


Following

This tab will display the Conversation, tags, documents of followed users

Everyone

It displays the conversation of everyone in organization

Mentions

It displays the mention of particular user and assigned tasks

Activities

It displays all the activities of user

Likes

It displays the items which is liked by user

I'm Following

It displays the count of People, documents, sites and tags the user following. We can get more details while clicking the numbers.

Trending #tags

It gives the top five # tags.

One Drive

This link redirect us to user's onedrive for business. Onedrive for business is a personal storage. User can able to store their documents and so. We can able to synchronize this with local computer.

Sites

It displays the sites which is followed by user and suggested sites.

About Me

About me is a default page while we are accessing another user's page. This page contains Activities, Edit your profile, In Common and Org Chart.

Blog

Blog is a webpart, it is used to publish the blog by site owner. User can able to customize the page as user want.

Apps

This page will displays the list, libraries and other apps

Tasks

This page will display the tasks which is assigned to user. This page is only visible to Site Owner.

Conclusion

I given some points about mysite in SharePoint 2013. You can get thrill while using those features in mysite.

Happy Learning !!!!

Friday, July 31, 2015

Document Center in SharePoint 2013

Introduction

SharePoint offers many things to maintains content. We are having libraries in every sites to handle this. If we are uploading thousands of documents, videos and pictures we can have separate site for this. That is called Document Center. It is working for both Authoring Environment and Content Archive

Authoring Environment

It is behaving like repository to handle documents and media assets.

Content Archive

We can able to store and view the documents. It will be looking like Knowledge base.

How to create Document Center

Here is the steps to create document center

  • Go to Site Contents
  • Click new Subsite
  • Give Title, Description and URL
  • Then, Choose Document Center template under Enterprise category
  • Click Create. Site will be created and redirect us to home page

Uploading Documents

Here is the steps to upload a document to the site
  • Click Upload Documents in home page
  • We will get new form to upload a document
  • Choose the document from computer and click OK
  • Select the Content Type and give title
  • Click Save
  • The document will be saved in Document Library
  • It will be displayed in Newest Documents and Modified by me

What's in Document Center

The Document Center is a place to upload a set of documents and manage in easier way. This site template will be ready with all needed feature of document management. It can be used as Authoring Environment or Content Archive.

Authoring Environment, is used to upload document with check in and check out option. Versioning will be enabled by default. And workflow can control the document life cycle.

In Content Archive,  We can able to upload and view the documents without versioning. We have only one major version in it. It will be behave like a Knowledge Base.

Other Features in Document Center site templates are,

Metadata Navigation

Managed Metadata System is used to assign terms to Document. This terms will used to categorized the document. It will be useful for users to navigate particular document

Document IDs

Each documents are having their own ID. This is IDs are not modified by anyone. Its not depends upon the document location. We can change the document location later but ID will not be changed.

Document Version

Versioning is enabled automatically in Document Center. That means Document Center will track of all the different change of document.

Conclusion

I have give some points about Document Center. Play with Document Center and get more knowledge.

Happy Learning !!!!!!!!!

Monday, July 27, 2015

Reset List Item ID in SharePoint

There is no option to reset the list item id in SharePoint. But we have an option in backend. We need to open a Content Database and Execute the Following query

Select * from AllListsAux where ListID = 'ListGUID' //This query is used to fetch the data of particular List


UPDATE AllListsAux set NextAvailableId=1 where ListID='ListGUID' //This query is used to reset List item id.

Note: Please be safe in all the aspects while doing this Content DB.

Thursday, July 23, 2015

How to enable Open with Explorer in Document Library

Most of us face this issue in document library. "Open With Explorer" is not enabled. To enable this do the following.

Run --> services.msc --> Start Web Client.

Set Startup by as Automatic.




Blog site template in SharePoint 2013

Introduction

Blog is one of the useful site template in SharePoint 2013. Here we are going to see about the features of Blog.


Blog site Creation

Steps to create Blog Site

  • Go Site Contents of Site Collection
  • Click New Subsite
  • Give Title, Description, URL for the site
  • Then, Select Blog template in Template Selection
  • Click Create 
We may get blog home screen after the creation.

Categories

We have an option to categorize our blog. We can able to see default categories on the left side of home screen. 

These are the default categories given by SharePoint. Each category will redirect us to their page which is list out the category blogs. We can able to create our own category also. Once you clicked the Add Category we may get new form to fill about category. 


Add Blog

Click Create Post in Blog Tool container.We may get new form for post. We need to give details of the blog like Title, Body, Category (Multiple category also available) and Published Date. Then click Publish

Blog will be displayed in home page.

Blog Tools

This is one of the container we have in the right side of home page. Let see options one by one

Manage Post

This option will redirect us to list view of blogs. We can able to see properties of blog like title, Created by, Published, Category, Number of Comments and like

Manage Comments

We can see all comments here and their properties like Title, Created by, Blog title. We can able to delete the unwanted comments here.

Manage Categories

We can able to see all the categories here. We can do add, edit and delete it.

Change Page Layout

We can able to change the page layout of home page. We have 3 layouts by default. The page will be changed based on the selected layout.

Conclusion

I given a small introduction about blog in sharepoint. We may get more knowledge while we work with this.

Happy Learning !!!!!!

Tuesday, July 21, 2015

Set Requird property for list column using powershell script

Here i am going to provide a script for set required property for list column.

$web = Read-Host "Enter site URL : "
$spweb= Get-SPWeb $web
Write-Host "Set Required attribute" -ForegroundColor Magenta
$list = $spweb.Lists["List Name"]
$field = $list.Fields["ColumnName"]
$field.Required = $true  //if you want to remove the required property give $false
$field.update()
$list.update()

Write-Host "Required attribute enabled" -ForegroundColor Magenta

Friday, June 26, 2015

Simple way to Add ListView Webpart in SitePage

We have so many option to add listview webpart in sitepage. Here, I am going to tell one of the simple method.

First create a module for site page. Then create a page under sitepage module. Open element.xml file. We can able to see <File> node of created sitepages. Insert the <view> node with their properties. For Example:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="SitePages" Url="SitePages">
    <File Url="test.aspx" Type="GhostInLibrary">
      <View List="TestList" BaseViewID="0" WebPartZoneID="Left" WebPartOrder="0" />
    </File>
    <File Url="test1.aspx"/>
  </Module>
</Elements>


Now Deploy the solution in web application. List view will be displaying in sitepage.

Wednesday, June 17, 2015

Update Farm Account in SharePoint 2013 (After changed the system password)

To update the farm account in SharePoint 2013:
In PowerShell command prompt:

stsadm -o updatefarmcredentials -userlogin domain\account -password password