Apr 16, 2012

The security validation for this page is invalid in SharePoint

Sometimes, when a user with least permissions in the SharePoint site, creates or updates an item, then the following error will be shown:
“The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again”

When you are creating a custom web parts or creating custom solutions, your code will run with your credentials.

Not everybody has full control in the SharePoint site, so when a user has read only rights and try to update an item in the list or SharePoint Document library, then the code will throw an access denied error. This happens, when the code needs access to objects that are not in the scope of the user credentials.
Here comes the concept called impersonation (ability to control the identity under which code is executed) in ASP.Net. This will allow you to run your code with the help of a user who has correct permissions to run it.

Namespace: Microsoft.SharePoint
Assembly   : Microsoft.SharePoint (in Microsoft.SharePoint.dll)

In SharePoint we have built-in function to accomplish this: SPSecurity.RunWithElevatedPrivileges, it runs with the System Account User.

Solutions:
1. Add the “SPSecurity.RunWithElevatedPrivileges = True” in the code as shown in the example below:

2. Or in the Central Administration -> Application Management -> Web Application General Settings -> Select web application
In Web Page Security Validation, change security validation is off.
Note: The 2nd solution is should not be followed as per the best practices of SharePoint.

Workflows in SharePoint

What is a Workflow in SharePoint?
Ø  In simple words, we can say workflow is a serious of activities occurs in steps which will produce an output at the final step.
Ø  In SharePoint, workflow is an automated movement of documents or items through a sequence of actions or tasks that are related to a business process
Ø  Business process is a sequence of steps that occurs on a document or a task or an item and finally produces a result as an outcome.

Types of Workflows
Basically, there are two fundamental types of workflows in the SharePoint:
                       
   1.   Sequential workflow
It represents the steps that execute in order until the completion of last activity. It is represented graphically in flowchart with start, end and all the sequential activities in between.
Example

   
  2.   State-Machine workflow
It represents a set of states, transitions and actions. As sequential workflows, it does not have prescribed execution flow and need not have an end. It can have any number of states and transition and it can any items related to any transition.
Example


The different types of workflow in the various versions of SharePoint present by default are listed below:

Ways for creating workflows in SharePoint
The different ways of creating the workflows in SharePoint are as follows:
    1.   In SharePoint site directly
    2.   SharePoint Designer
    3.   Microsoft Visual Studio with workflow extensions installed (WWF- Windows Workflow Foundation) – basically called custom workflows
    4.   Third party tools like K2 Black Perl, Nintex, etc.,

What are the pre-requisites for creating a workflow in SharePoint?
    1.  There should be a at least one list or document library to create and associate a workflow.
    2.   If you do not have a single list or document library in your site, you will be prompted for creating a list or library.
    3.   If you want your workflow to be associated with custom columns or settings in the site, then those changes should be made before you create the workflow so that it will be available in the designer.

Advantages
 Ø  Allow the business activities to be automated, enabling actions such as document review, approval, issue tracking and signature collection.
 Ø  Allow the document to be routed to one person to another for approval by assigning a task to each person. This is followed by analysis, review, and approval and finally the document is published. Hence making the document management easier.
 Ø  Also improves the collaboration in an enterprise.

To know about creating a designer workflow in SharePoint using SharePoint designer 2007, read this article.


To know about the new features added in SharePoint Designer 2010, read this article.

Apr 7, 2012

Exporting SharePoint User Groups with Group Names

In the article Exporting SharePoint User Groups into Excel, we have learned about exporting the SharePoint user groups into excel. Here we are able to export all the users in a SharePoint site but we are unable to sort the users with the group name.
In this article, we will learn a small work around filter the users with the group name.
We can use SQL Query to fetch this data.
Connect to the SQL server and open a new query in the content database where your SharePoint site resides.
The SharePoint content DB does not expose the tables (for lists, libraries, users, etc.) in the database directly.
The below is the query which will fetch all the users in the SharePoint site with the user groups in a separate column in the result.
SELECT dbo.Groups.ID, dbo.Groups.Title, dbo.UserInfo.tp_Title, dbo.UserInfo.tp_Login FROM dbo.GroupMembership INNER JOIN dbo.Groups ON dbo.GroupMembership.SiteId = dbo.Groups.SiteId INNER JOIN dbo.UserInfo ON dbo.GroupMembership.MemberId = dbo.UserInfo.tp_ID
Hope this helps you!
Please free to comment. Always your comments makes me to write more!

Mar 19, 2012

The Search Service is currently offline

Problem:
The search service is currently offline. Visit the services on server page in SharePoint central administration to verify whether the service is enabled. This might also be because an indexer move is in progress
You will get the below screen when you navigate to the default content access account, crawl log or default content access account in the Search Server Administration.
Resolution:
Following are the steps to fix this issue.
  1. Open central administration
  2. Goto Operations -> Topology and Services -> Services on Server
  3. Select Search Indexing -> On “Office SharePoint Server Search” click “Stop”. This will reconfigure the service
  4. Now click “start”
  5. Navigate to the indexer log file location which is C:\Program Files\Microsoft Office Servers\12.0\Data\Office Server\Applications” for me. Here you will find a folder with Guid name. At the end of that folder add “_old”. Refresh the SSP page and wait for some time and now the indexer will recreate the guid folder.
  6. This will fix this issue.
If this doesn't work out, then check the service account which is running the search service (default content access account for crawling the content). If there are any changes in the account, then this might also be the problem for the search service to go offline.

Please free to comment. Hope this helps you!

Configuring Enterprise Search in SharePoint 2010

Hi All,

Read the useful arcticle which explains about Configuring the Enterprise Search in SharePoint 2010. A step by step explanation with screens is explained in this artcile.

Configuring Enterprise Search in SharePoint 2010 

Mar 18, 2012

Inserting a web part into SharePoint page without designer

In the article “Inserting a web part into SharePoint Page without designer”, we have discussed about inserting a web part in New/Edit/Display from.aspx in without using designer the lower versions of SharePoint (WSS 3.0 and MOSS 2007).
Now, in this article we will discuss about inserting a web part into the New/Edit/Display form.aspx page without designer in SharePoint 2010.
Now, suppose that we have custom list named “City”
Now, go to the List Settings of the custom list “City”

Under General Settings -> Advanced Settings

In the advance settings, we have an option for the Launching the forms in dialog when click on NEW for inserting a new value in a list.
Here, now we will disable that option by selecting NO in launch forms in a dialog as shown below:



Now, we will click on “New Item” for inserting a new item in the custom list

Now, we will be navigated to the newform.aspx without popup dialog since we have disabled it.

The URL in the address bar will be as below:
In the above URL delete the URL before NewForm.aspx, we will have
In this URL in the address bar, append “?ToolPaneView=2”

Click Go in the address bar, then you will see the Add Web Parts option for inserting into the newform.aspx page.


In the similar way, we can insert the web part into editform.aspx and displayform.aspx

Mar 17, 2012

The Parameter is incorrect crawl error Search Server


In this article, we are going to discuss about a strange issue with Microsoft Search Server.
Scenario:
Usually with the SharePoint, we will install Microsoft Search Server for providing the users a search function.
We will configure the content source in Search Server Admin page and crawler indexes the contents and will display the results in the search depending upon the user query.
The below figure shows the Search Server Overview:

Content Sources – The link where the SharePoint site is configured for crawling
Crawl Log – The logs of the crawler
Sometimes we will get the “The Parameter is incorrect” in the crawl log and then onwards, the search server stops crawling the new contents and no results will be displayed in the search result.
Root Cause:
This is due to a limit that a SharePoint user group cannot have more than 1000 users in a single SharePoint group.
Resolution:
The only way is to either decrease the number of users in the group which has exceeded the 1000 users or to split the user groups (Check the reference article below).
The reason behind is
During the indexing process, the system stores the ACE of each user who was added to a SharePoint group instead of the ACE of the SharePoint group itself. This process supports approximately 1000 users per access control list (ACL), after which the "Parameter is incorrect" error causes crawling to fail.
Reference Article:
Thanks for reading. Share your feedback!

Mar 12, 2012

Export SharePoint User Groups in Excel

In this article, we are going to discuss about a SharePoint tip which is not present in the User Groups by default.
Scenario:
From any list in the SharePoint, you can export the whole list in to a excel file or you can edit and save the excel file.
But is that possible in SharePoint User Groups?
Yes, it is possible.
Solution:
1. Go to Site Settings (http://sitname/_layouts/settings.aspx) -> Under Users and Permissions Select People and groups 
2. You will be seeing a URL like this http://sitname/_layouts/people.aspx?MembershipGroupId=5
3. Then navigate to the List Settings in the people and groups of a particular group which you want to export to the excel file

4. Now, in the URL you will see like this:
http://sitname/_layouts/listedit.aspx?List=72bcbfee-c10e-41ba-b128-2769c8fe9cc9&Source=%2Fpeople%2Easpx%3FMembershipGroupId%3D5
5. If you want you retrieve the users list from any view, then click on the view from the views list as shown below:
Scroll to the bottom of the page and click on the view you want to export
6.Now, copy the URL from the address bar and keep it in a notepad which is something like below:
http:// sitname /_layouts/ViewEdit.aspx?List=%7B72BCBFEE%2DC10E%2D41BA%2DB128%2D2769C8FE9CC9%7D&View=%7B4A52DE00%2D9B7C%2D4FDC%2DAC39%2D960FDF18F1F3%7D&Source=%252F%255Flayouts%252Flistedit%252Easpx%253FList%253D72bcbfee%252Dc10e%252D41ba%252Db128%252D2769c8fe9cc9%2526Source%255Flayouts%25252Fpeople%25252Easpx%25253FMembershipGroupId%25253D5
From the above URL, we have to copy the LIST ID and VIEW ID (marked bold in the above URL)
7. Now, we can easily export the people and groups in to excel using the following dll from the SharePoint server.
http://[sitename]/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=[LISTID]&View=[VIEWID]&CacheControl=1
8. Now, replace the site name, LIST ID and VIEWID in the above URL:
I will get the final URL as:
http://sitename/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=%7B64DAB4AC%2DD043%2D4DA4%2D85C7%2D9D4521C3F4CC%7D&View=%7B0FAE8D90%2D59D5%2D48F4%2DA54E%2DF02333777C7F%7D&CacheControl=1
Note:
To know more about the owssvr.dll please read this article
Open the above URL in the address bar, you will get an option to save an EXCEL FILE.
9. Open the Excel file, you will be asked for authentication, enable the external content and open it.
10. That’s it. You will see all the users in the groups with their details exported to the excel file.
11. This excel file exported using this method has all the users from the user groups but it is not filtered by user group name.
Read this article to achieve exporting the SharePoint user groups with the group name Exporting SharePoint User Groups with Group Names.
Read this article to know How to Programmatically get the users with the Group Name in SharePoint 

Mar 10, 2012

SharePoint Web Part Maintenance Page

In this post, we will come to know how to navigate to the web part maintenance page.

Why we need this page in SharePoint ?

In the webpart maintenance page, we will see the web parts present in a SharePoint page.
By adding “?contents=1” at the end of the page URL, you can navigate to the web part maintenance page.

For Example:

Here, you can see the web parts present in the SharePoint page and you can delete the web parts if it is corrupted or not used in the particular page.

Advantage:
There will be scenarios like; you will get an error while opening the SharePoint page in the SharePoint designer. Read this article to know more Deafult.aspx is not opening in the SharePoint Designer


Feb 13, 2012

Cascading dropdown (or) Filtered Values in Lookup Columns in SharePoint

Update: 27/06/2017
To know about implementing Cascading drop down or filtered lookup in SharePoint 2013 or SP Online using REST API, read this article: Cascading drop down in SharePoint using REST APIUpdate: 06/07/2017
To know about implementing multi-value lookup column and filtering values, read this article: Multi value Lookup Columns in SharePointTo know about the Basics of Lookup Columns read this article.Also, to know about the Enhancements of Lookup columns in SharePoint 2010 read this article.
Problem:
In SharePoint the cascading or the filtered values in the lookup columns are not present by default.
In this article, we will achieve this using the simple JavaScript.
Solution:
Consider the simple scenario that the user needs to input the values of Continent, Country, State and City which has to be the filtered values.
Steps:
1. Create four lists with the following column and corresponding types
Note: 
I haven’t used the default title column for any of the lists above and I have hide it from the default view.
To know how to hide the default title column from the list read this article.
2. The screen shots of the four custom lists created in the step 1 are shown below:




3. Now, we will create another custom list for testing the cascading dropdown in the SharePoint. Create a custom list with the following column and corresponding types
The screen shot of the created list is shown below:
4. When we click on the dropdowns in continent, country, state or city we will get the unfiltered values as shown below:
5. Now we add the java script to achieve the solution
General Code to be added:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Execute the following JavaScript after the page has fully loaded, when it's ".ready"
$(document).ready(function(){
    $().SPServices.SPCascadeDropdowns({
        relationshipList: "Display Name of Master List",
        relationshipListParentColumn: "Parent Column Internal Name from Master List",
        relationshipListChildColumn: "Child Column Internal Name from Master List",
        parentColumn: "Parent Column Display Name from List/Library",
        childColumn: "Child Column Display Name from List/Library"
    });   
});
Description of the code
Note:
To know how to get the Internal Name of a column in a list in SharePoint, read this article.
Download of JQuery referred in the code can be found from jquery.com and codeplex.com
For ease of download for the readers, I have uploaded the script in the below links. Click to download the jquery-1.4.2.min.js and jquery.SPServices-0.5.3 min.js
Code in our case:

6. Now, we will insert this JQuery and achieve the cascading dropdown.
7. Click on New in the created custom list (Cascading Lookup Demo) as shown below:
8. Now, we will insert a Content Editor Web Part in the newform.aspx to place the JavaScript code in it.
 To know how to insert a web part in the NewForm.aspx without using SharePoint Designer read this article.
9. After inserting the web part, paste the code and save the web part.
Note: Place Content Editor Web Part below the list form or else the Java Script added won’t work.
10. We are done! Now, we will check the cascading drop down. So, when the continent is selected only countries with respect to the continent should be displayed (Filtered values) and then the state, city in the same case.
The results of various scenarios are shown below:


I have checked for the empty values scenario also. What if the child column is empty or does not contain values. Then after inserting the value, it should add empty values in the column as shown below:
After inserting the values the list is as follows: 
Advantages:
Ø  We can simply achieve the cascading drop down in lookup columns in SharePoint without using any third party tools
Ø  No need of SharePoint designer to achieve this result
 Disadvantages:
Ø  This won’t work in the Data Sheet View since we are inserting the J query in the aspx page only.
Ø  When the number of items in a look up column is greater than 20 then your drop down will change as follows:
We had more than 20 states in the States List (28 items with lookup values)
This happens only in the IE and not in the Chrome or any browsers.
Have a look at the page in the Chrome Browser:
The reason for this variations and the fix is explained well in this article. Below is the link
Hope you have read a nice article.
Please free to comment. Always, your comments help me to write more.
Share this post to others if this helps you!
Note:
I have updated the code of this article on 08.06.2012 since readers of this article requires the following:
1. What is the case if there are more than 2 values (4 cascading or filtered values – using more number of variables)?
2. What is the case if there is an empty string in the child value?
3. To explain the solution with more details for ease of reading and understanding for the readers.
Update: 27/06/2017To know about implementing Cascading drop down or filtered lookup in SharePoint 2013 or SP Online using REST API, read this article: Cascading drop down in SharePoint using REST APIUpdate: 06/07/2017To know about implementing multi-value lookup column and filtering values, read this article: Multi value Lookup Columns in SharePoint