Wednesday, December 21, 2011

IE & Sharepoint 2010 UserProfile Cache Issue

When you using Windows Authentication (NTLM + AD) with your sharepoint site you may want to enter credential after you sign out from your site.But it is not easy and somehow imposible when using authentication NTLM and IE .Beacuse after you sign out and try to login again ,automatic login proccess logs you in immediately.

I can explain you two alternative way two prevent automatic log on.
First solution which is my suggested way. Dont use windows authentication . Use Claim Based Authentication (CBA)+ (Forms Based Authentication) FBA with Active Directory (AD) membership.

http://blogs.msdn.com/b/sridhara/archive/2010/01/07/setting-up-fba-claims-in-sharepoint-2010-with-active-directory-membership-provider.aspx
And Second way:
1) Upload jquery 1.4.1.1.js file in one of your library and copy the path.
Edit your v4.master and add fallowing js codes. (Using JQuery)

<script type="text/javascript" src="<<Path of the jquery library >>"></script>
<script type="text/javascript" >
$(document).ready(function(){$("#zz15_ID_Logout").attr("onMenuClick","STSNavigate2(event,'/SitePages/logout.aspx');");});
</script>
 
2) create a new “logout.aspx” page which masterpage is v4.master using Sharepoint Designer

3) add the fallowing code to your new sign out page
<script type="text/javascript">
function _spBodyOnLoad()
{
try
{
   /* Note : this command is support with only IE  */
  document.execCommand("ClearAuthenticationCache",false);
}
  catch (e) { }
  window.location='/_layouts/signout.aspx'; 
}
</script>
4) For testing choose a different machine than sharepoint server and configure your browser Tools->Internet Options->Security->Local Intranet
Click Custom Level and find Logon and change it to “Prompt for user name and password”
And be sure your site not added to trusted zone sites.


Login your site and type your browser’s addres bar
http://[SharepointSiteURL:port]/SitePages/logout.aspx and press enter
Try again to login and see asking your credentials.
when your sharepoint site url does not contain dot “.” that IE suppose that its a Local Intranet site. Thats why we changes the Local Intranet Zone settings to “Prompt for user name and password”

Monday, December 12, 2011

SharePoint Sites Keeps Asking Users to Login

Goto
Computer Configuration | Policies | Windows Settings | Security Settings | Local Policies | Security Options: Network access: Do not allow storage of credentials or .NET Passports for network authentication - set it to Disabled.
As explained in GMPC:
Network access: Do not allow storage of credentials or .NET Passports for network authentication

This security setting determines whether Stored User Names and Passwords saves passwords, credentials, or .NET Passports for later use when it gains domain authentication.

If it is enabled, this setting prevents the Stored User Names and Passwords from storing passwords and credentials.

Note: When configuring this security setting, changes will not take effect until you restart Windows.
For more information about Stored User Names and Passwords, see Stored User Names and Passwords.

Default: Disabled.
Equivalent registry hack: HKLM\System\CurrentControlSet\Control\Lsa\disablecreds
Value type: REG_DWORD
Value: 0 = allow domain credentials  to be stored

Wednesday, November 30, 2011

Attaching Content Database to Web Applications

To attach a content database to a Web application by using Windows PowerShell

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.
  2. On the Start menu, click All Programs.
  3. Click Microsoft SharePoint 2010 Products.
  4. Click SharePoint 2010 Management Shell.
  5. At the Windows PowerShell command prompt, type the following command:
    Mount-SPContentDatabase -Name <DatabaseName> -DatabaseServer <ServerName> -WebApplication <URL> [-Updateuserexperience]
    Where:
    • <DatabaseName> is the name of the database you want to upgrade.
    • <ServerName> is server on which the database is stored.
    • <URL> is the URL for the Web application that will host the sites.
    • Updateuserexperience is the choice to update to the new user experience or stay in the old user experience (part of Visual Upgrade). When you include this parameter, the site is set to preview the new user experience. Omit this parameter if you want the site to remain in the old user experience after upgrade. For more information, see Plan visual upgrade (SharePoint Server 2010).
For more information, see Mount-SPContentDatabase.
noteNote:
We recommend that you use Windows PowerShell when performing command-line administrative tasks. The Stsadm command-line tool has been deprecated, but is included to support compatibility with previous product versions.

To attach a content database to a Web application by using the Stsadm command-line tool

  1. On the drive on which SharePoint Products and Technologies is installed, change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\14\Bin.
  2. Type the following command, and then press ENTER:

    stsadm -o addcontentdb -url<URL> -databasename<DatabaseName>

    [-databaseserver<ServerName>] [-databaseuser<UserName>]
    [-databasepassword<Password>] [-sitewarning<SiteWarningCount>]
    [-preserveolduserexperiencetrue/false]
    [-sitemax<SiteMaxCount>]
    [-assignnewdatabaseid][-clearchangelog]

Tuesday, November 15, 2011

Create a Web Part Page WITH a Quick Launch Menu in SharePoint 2010


The default web part pages will lose the Quick Launch navigation, so I usually create a blank ASPX page instead. These are the steps to take to create your own web part page. This is also a useful method for creating custom form pages for your lists.
  1. Create a document library to put your web part pages in.
  2. Open your site in SharePoint Designer, and click File –> New –> ASPX
  3. Right Click the page and open in Advanced Mode.
  4. Select Style Menu and choose Attach button on the Ribbon and select Default Master Page., and click Attach Master Page
  5. Click OK for the Default Master Page.
  6. Click the PlaceHolderMain section in the middle of the page, click the little chevron (the little gray button with an arrow on it), and click Create Custom Content.
  7. Put your cursor inside of the PlaceHolderMain section. On the Insert Menu, choose SharePoint Controls, and click Web Part Zone.
  8. Click File and Save As, and save it to the document library that you created at step one.
Now you have a blank web part page that DOES contain the Quick Launch navigation on the left. You can either add web parts here in SharePoint Designer, or from the browser.

Note: If you’d like to have multiple web part zones, step 6 would be to create a table first, and then insert the web part zones into each cell of the table.

 Happy SharePointing!!!

Thursday, November 3, 2011

Create a SharePoint 2010 web part page that inherits the site's left navigation

The SharePoint web part page in SharePoint 2010 does not have a Left Navigation, by default you will have a page that has the top (global) navigation, but no current navigation on the left. This may be exactly what you want, as you will have a bit more space to work with. If you want to show the current navigation on the left hand side of a web part page, here is how to do it:

image

  1. Go to the page that you want to add the left navigation to
  2. Go to Site Actions – and launch “Edit in SharePoint Designer”. This will open the site in SharePoint Designer 2010. You’ll need to navigate to the actual location where the web part page is (usually Site Pages). Open the page you want to edit.
  3. Make a copy by right-clicking on the page, choosing copy, and then choosing paste
  4. Right-click on the (copy of) the page you are going to edit to add the left-nav, and choose Edit File in Advanced Mode
    image
  5. Scroll to (or search for): body s4-leftpanel. Once you find it, you’ll want to comment out the following code:
       1: <%-- <style type="text/css">
       2:  body #s4-leftpanel {
       3:     display:none;
       4: }
       5: .s4-ca {
       6:     margin-left:0px;
       7: }
       8: </style> --%>

  6. Scroll to (or search for): PlaceHolderNavSpacer and comment out the following two lines.
   1: <%-- 
   2: <asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server"></asp:Content>
   3: <asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"></asp:Content> 
   4: --%>
Save the page, preview in browser, and voila! Your current navigation is now on the left. If you like the changes, rename your copy to the original filename and you are all set to go!
image 

Happy SharePointing.!!!

Wednesday, November 2, 2011

Update SharePoint 2010 Farm Credentials

Within your SharePoint environment – such as your PowerPivot for SharePoint single server install – a common task that you will need to do is to update the SharePoint Farm credentials when the password changes. You may be able to do this automatically by using the new SharePoint 2010 feature to plan automatic password change.
But if you need to change your farm credentials, you can follow the instructions: How to change service accounts and service account passwords in SharePoint Server 2007 and in Windows SharePoint Services 3.0.
But in the process of updating a PowerPivot for SharePoint single server install, I realized that a few additional tips that may prevent you a few hours of debugging.
  • Since its SharePoint 2010, Step 1a is now the c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Bin folder.
  • The update farm credentials step Step 1b is still (i.e. No change)
stsadm –o updatefarmcredentials –userlogin DOMAIN\username –password $password$
  • Steps 4 and 5 are not required unless you’re running SharePoint Search. In most PowerPivot for SharePoint installations, this service is not running so you don’t need to do these steps
  • Step 6 is not necessary as SharePoint 2010 is using service applications (as opposed to SharePoint 2007 using shared services providers). Though you will want to ensure to update your managed accounts for any services that are using the same account as your farm account.
As well, here are some other good reminders:
  • You should login to your server using the farm account to ensure that you have the rights to run the above commands
  • Make sure that the SQL Server service for your SharePoint databases (for example, the SQLSERVERNAME\POWERPIVOT) is running (from services.msc). Often in PowerPivot for SharePoint installs, the startup account for SQL server and the farm account are the same. If you need to update the password, it is likely that the SQL Server service is not running because the credentials are no longer valid.
  • If you’re still running into issues when running the updatefarmcredentials command, you may want to apply the same step for the SQL Server service to the SharePoint 2010 Timer service.
Hope this helps!

Tuesday, November 1, 2011

How to configure PDF iFilter for SharePoint Server 2010 or Search Server 2010


I recently installed and configured Search Server 2010 Express on my VMware machine for evaluation purposes. Once I configured basic steps to configure Search Centre site and necessary settings, I decided to install PDF iFilter (x64). Last year, I posted a similar article on how to install and configure PDF iFilter for SharePoint 2007 (64bit), which can be found at http://www.mossgurus.com/adnan/Lists/Posts/Post.aspx?ID=9. I didn't find a single decent article on Google, which clearly explain the process of installing and configuring PDF iFilter for SharePoint Server 2010 or Search Server 2010 Express edition. So I decided to follow my own article and I was hoping that it should be straight forward to install and configure PDF iFilter for SharePoint 2010. Apart from updating the registry settings required to update GUID for .pdf, remaining steps are similar.

Follow the steps below to install and configure PDF iFilter on SharePoint Server 2010 or Search Server Express 2010.
  1. Install PDF iFilter 9.0 (64 bit) from here.
  2. Download PDF icon file from pdf16.gif and copy at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\.
  3. Add the following entry in docIcon.xml file, which can be found at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML.
    <Mapping Key="pdf" Value="pdf16.gif" /> 
  4. Add PDF file type on the Manage File Type page under Search Service Application.
  5. Open registry by executing regedit on the Start --> Run.
  6. Navigate to the following location:
    \\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\
    14.0\Search\Setup\ContentIndexCommon\Filters\Extension 
  7. Right-click Extension, a menu will appear.
  8. Click New--> Key to create a new key for .pdf. See screen shot below:
  9. Enter .pdf and save key.
  10. Now add the following GUID in the default value as shown in the figure below.
    {E8978DA6-047F-4E3D-9C78-CDBE46041603} 
  11. If you are configuring SharePoint Server 2010, then restart Search service by executing the following command on the command line:
    net stop osearch 
    net start osearch 
  12. If you are configuring PDF iFilter on Search Server 2010, then restart the SharePoint Server Search 14 service as shown in the figure below:
  13. Perform incremental to include PDF files.
  14. PDF iFilter is successfully configured. Now you can search for the content of PDF file. See screen shot below:
Note: SharePoint Server 2010 or Search Server 2010 Express provides out of the box search support for .ZIP files, so you download and have to install Microsoft Filter pack as you used to do with MOSS 2007.

Monday, October 24, 2011

Adding Custom Context Menu Item to Edit Control Block in SharePoint 2010

Within SharePoint 2010, there is a ‘context menu’ that is shown when you click on a specific file – eg. DOCX.
image
This is actually known as the “Edit Control Block” or ECB. Yep – another acronym for the kitbag.
To add functionality to the SharePoint 2010 ECB, we have to create a new SharePoint feature, with some XML within an ELEMENTS.XML file.
Here’s the steps to follow :
  • Open Visual Studio 2010
  • Click on “Empty SharePoint Project”
  • Name the project : NewContextMenuButton
  • Choose to ‘deploy as a farm solution’ when prompted
Within the new project, we need to add a new ‘elements’ file – and subsequent feature, etc.
  • Right-click on the project, and choose Add > New Item
  • Choose ‘Empty Element’
  • Enter the name as : NewContextMenuButton
  • Click CTRL+A (select all) and then Delete.
  • Paste in the following XML
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>
<CustomAction Id=”SPR.CustomButton”
RegistrationType=”FileType”
RegistrationId=”docx”
Location=”EditControlBlock”
ImageUrl=”/_layouts/IMAGES/DOCLINK.GIF”
Sequence=”600″
Title=”Custom Button”
Description=”Click this button to see something magical occur…” >
<UrlAction Url=”javascript: alert(‘Hello World !’)” />
</CustomAction>
< /Elements>

You can now simply right-click – and choose DEPLOY – that’s it…! The feature & package name will be the default values – but they can be changed if needed.
Also – the IMAGE being used was just something that I found in the ‘layouts’ area of SharePointRoot.
Here’s the new Context Menu item – sorry, new addition to the Edit Control Block :
image
This will create a new entry for “DOCX” files – based on the “RegistrationType”.

Create rich HTML email message in Sharepoint Designer 2010 workflow


The Sharepoint designer 2010 workflow email body action is not a rich HTML, its not supported with this version but i found a quick way to add rich HTML in email body message.
Here is the steps:
  • First create your HTML in dreamweaver or vs2010 or any other HTML editing tool
  • Then open your workflow in SPD 2010
  • Add “Send email” workflow action from ribbon
  • Keep “Send Email” action selected/highlighted
  • Then navigate to ribbon and select advanced properties
  • Select last option Body
  • Click on the button (...) to open the text pad
  • paste your html including head,body and html.
  • Click OK and open the action from workflow step
  • Then add your lookups and test it.
  • Done!

Friday, October 21, 2011

Custom Blog Rollup Using Content Query Web Part


There are a few posts dealing with CQWP customization but most of them use the publishing pages. A few requests have been posted to customize blog posts using CQWP and there is something specific to this request: the CQWP does not output the blog post body out of the box. Before I describe the process, I should give credit to the blog post by Heather Solomon (2007, but still valid for 2010).
There are two main steps in this process: customize the ItemStyle and the CQWP. You can find the reference on adding properties to the CQWP at this MSDN article.
So, we export the CQWP and edit the line that has CommonViewFields to become <property name=”CommonViewFields” type=”string”>Body, Note</property>
Here, Body is the post body text and Note is its type (yes, it’s not RichHtml as you may think), but how do we know? You check the schema file at \14\TEMPLATE\FEATURES\DiscussionsList\Discuss
Now that we have the field available in the CQWP, we edit the item style. The ItemStyle.xsl file lives in the Style Library in your site collection (only there, one style library per site collection) inside the folder XSL Style Sheets (that’s easy to figure out). You download the file and open it in a text or xml editor. Here, we will copy the default style and paste it under the original (starts with <xsl:template name=”Default” match=”*” mode=”itemstyle”> and ends with </xsl:template> – around 67 lines). Of course, we need to name our style – I replaced the first line by <xsl:template name=”AKTemplate” match=”Row[@Style='AKTemplate']” mode=”itemstyle”> You will notice we have a few blocks of xsl variables and I added my new one under the last one (Display Title)
<xsl:variable name=”bodyContent”>
<xsl:call-template name=”removeMarkup”>
<xsl:with-param name=”string” select=”@Body”/>
</xsl:call-template>
</xsl:variable>
We will get back to the removeMarkup soon (I used the same one by Heather).
The code starting with <div class=”item”> is where we show the data, so I added
<div class=”description”>
<xsl:value-of select=”substring($bodyContent,1,75)”/> … (<a href=”{$SafeLinkUrl}” mce_href=”{$SafeLinkUrl}” target=”_blank” title=”{@LinkToolTip}”>More</a>) </div>
</div>
just before the last </div> in that block (close to the end of the template). Here, I am taking the first 75 characters of the clean text and added a link to see the full post.
Finally, I added the template that strips out html tags right after the closing tag of my custom template (</xsl:template>). The removeMarkup template is available from Heather’s post toward the end and is clearly marked.
Save the xsl file and re-upload to the styles library (xsl style sheets folder). You need to publish a major version for this to work (not only check it in).
Now, you add a web part to your page based on the exported and adjusted one (under the web part groups, locate the Upload web part then select from imported web parts). Configure your CQWP and select your new item style (do not add Body; in the Description field!). If you did not have typos, you should see something similar to the above screen shot. If your itemstyle is not correct, your CQWP will not show and will give error (add ?contents=1 to the url and delete it, then roll back to the previous version of the itemstyle until you fix the custom one). See more on Heather’s blog on how to see available fields and find types etc.

Thursday, October 20, 2011

Send e-mail in a SharePoint Designer Workflow with dynamic string and images.

Send e-mail in a workflow with dynamic string and images.

We can create Email body with HTML tags to build a dynamic string

MOSS 2007
 Eg: Please find the Item URL: <a href="http://<sharepoint site>/Lists/Anouncements/dispform.aspx?ID=[%Current Item:ID%]">Announcement Item</a>

To have images in e-mail body we can use IMG HTML tag. Store image in your site sitecollection images library and copy the exact URL of image.

<img src="http://<Sharepoint site>/SiteCollectionImages/test.jpeg"/>


http://office.microsoft.com/en-us/sharepoint-designer-help/send-e-mail-in-a-workflow-HA010239042.aspx



SharePoint 2010:


Open the add a Hyper link Icon and Enter Text to Display and Address of the URL as

http://<sharepoint site>/Lists/Anouncements/dispform.aspx?ID=[%Current Item:ID%]. This will create a Dynamic URL in the Email Body.




Happy SharePointing !!!

Wednesday, October 19, 2011

Creating custom views on Survey in Sharepoint

For other lists within sharepoint we have an option of
creating our own custom views.


(Settings-CreateView).

However we have no such option in case of Survey. To create
our own custom view in case of survey we can do the following


First get the id of your survey. For this select view source
of the following page



You can get the id of the survey at following line

href=”/_layouts/listfeed.aspx?List=545889cc%2D1be0%2D463d%2Dbaa2%2D6dbec360ba68″

The id of the survey list is – 545889cc%2D1be0%2D463d%2Dbaa2%2D6dbec360ba68

Or

545889cc-1be0-463d-baa2-6dbec360ba68


%2D is equal to -


Now we need the url where in we
will use the above list id for creating custom view

For this create a simple IssueTracking
list or any other list for which we have an option of creating custom view.

Now select setting–>create
view for that newly created list


Copy the url

http://servername:12345/_layouts/ViewType.aspx?List==%7B59C5C613%2D11FB%2D44D8%2DB29E%2DC973006C062A%7D&

Source=http%3A%2F%2Fd%2D1246%3A12345%2FLists%2FDemo%2520tasks%2FAllItems%2Easpx



Get this much part of the url


http://servername:12345/_layouts/ViewType.aspx?List==%7B59C5C613%2D11FB%2D44D8%2DB29E%2DC973006C062A%7D



%7B is equal to {


%7D is equal to }



Modify it in the following manner


http://servername:12345/_layouts/ViewType.aspx?List={545889cc%2D1be0%2D463d%2Dbaa2%2D6dbec360ba68}



or 



http:// servername:12345:12345/_layouts/ViewType.aspx?List={545889cc-1be0-463d%2Dbaa2-6dbec360ba68}


i.e replace the list id.


Now you should be able to create your own custom views on surveys.


This is an Excellent job by  Nishant Rana.

Tuesday, October 11, 2011

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Cause of Error:
When we call Response.Redirect("") from try/catch block in asp.net, you will receive above error.
 
Example contains error:
try
{
string strRedirectUrl = Session["ReturnUrl"].ToString();
Response.Redirect(strRedirectUrl);
}
catch(Exception ex)
{
Response.Redirect("Default.aspx");
}


Solution:
Make second argument of response.redirect("MyPage.aspx",false);
Example containing solution:
try
{
string strRedirectUrl = Session["ReturnUrl"].ToString();
Response.Redirect(strRedirectUrl,false);
}
catch(Exception ex)
{
throw ex;
}
 

Thursday, October 6, 2011

People Picker Control in VS2010 to get the SharePoint Users Email

Using People Picker Control in VS2010 to get the SharePoint Users Email, First Name,.......etc.

Use the following tag in your Visual Web part user control
<SharePoint:PeopleEditor ID="myPeoplePicker" runat="server" SelectionSet="User" />
To access the user email id entered in the control, use the following code
PickerEntity pckEntity = (PickerEntity)myPeoplePicker.ResolvedEntities[i];
string email = pckEntity.EntityData["Email"].ToString();
 
http://karinebosch.wordpress.com/sharepoint-controls/peopleeditor-control/
 Thanks to Karine Bosch! 
 
Happy SharePointing!!!.

Setting Custom Workflow Status with existing and Custom Values

Workflow has few inbuilt status values such as "In Progress", "Completed", "Error Occurred", "Stopped" and "Failed on start". But what if we want to set a custom value for the workflow? A value, which we want the workflow to show whenever it is in progress or completed.

We can set a custom value for the workflow but this can only be done when we are designing our workflows in visual studio. Unfortunately, we cannot do this OOTB or using SharePoint Designer.
This can be done in both, Visual Studio Sequential workflows as well as Visual studio State Machine Workflows. To do this, open your workflow.xml and search for "" tag. Place the cursor just above it and write the below code :

"<"ExtendedStatusColumnValues">"
"<"StatusColumnValue">"Approved"<"/StatusColumnValue">"
"<"StatusColumnValue">"Rejected"<"/StatusColumnValue">"
"<"/ExtendedStatusColumnValues">"

(Please remove "" while writing this in workflow.xml as here it was not accepting the tags)
Now open the designer page and drag a "SetState" activity from your left hand side toolbox. Always Remember, there are two "SetState" activites, one is for setting the state in State Machine workflows and other is for setting the Workflow status to a custom value. The activity with a blue mark in it is used for setting the workflow status. Once you drag the "SetState" activity on the Designer page, right click on it and open its properties. Bind its "State" properties to a variable and select "field" while binding it. Select the correlation token as "WorkflowToken" as this activity does not belong to any task. Now double click the activity and you will come to the page where you need to write some code.

Let us assume that your "SetState" activity name is "PendingState". When you double click on the "SetState" activity, write the below line on the code window : 
 
PendingState.State= 0; // 0 to 14 are reserved status for workflow.
PendingState.State = (Int32)SPWorkflowStatus.MAX;

The integer value of the MAX is 15. From 0 to 14, the numbers are reserved for internal and builtin values such as InProgress, completed, error occurred etc. In workflow.xml, the value of the first custom value will be 15 (See above as we specified the first custom value as Approved). And then it will keep on increasing by 1. Like if we want to assign the "Rejected" value to the workflow then we will write the below line of code :

PendingState.State = (Int32)SPWorkflowStatus.MAX + 1;

The above line will assign the "Rejected" custom value to the State variable and whenever workflow reaches this state then it will show the status "Rejected". Like this we can write any number of custom values to the workflow. We have used only two custom values in the above Workflow.xml. If we want to use a third one then we will right it just below the "Rejected" custom value like :

"<"ExtendedStatusColumnValues">"
"<"StatusColumnValue">"Approved"<"/StatusColumnValue">"
"<"StatusColumnValue">"Rejected"<"/StatusColumnValue">"
"<"StatusColumnValue">"Pending"<"/StatusColumnValue">"
"<"/ExtendedStatusColumnValues">"

The value of "Pending" status will be assigned as follows :

PendingState.State = (Int32)SPWorkflowStatus.MAX + 2;

If you change your workflow.xml file by changing the workflow custom values then deploy it again and run iisreset to see the changes in SharePoint List when the workflow will run.


Wednesday, October 5, 2011

SQL Server 2008 The Save (Not Permitted) dialog box

The Save (Not Permitted) dialog box warns you that saving changes is not permitted because the changes you have made require the listed tables to be dropped and re-created.
The following actions might require a table to be re-created:
  • Adding a new column to the middle of the table
  • Dropping a column
  • Changing column nullability
  • Changing the order of the columns
  • Changing the data type of a column
To change this option, on the Tools menu, click Options, expand Designers, and then click Table and Database Designers. Select or clear the Prevent saving changes that require the table to be re-created check box.

Cannot import webpart on SharePoint site

When i deploy my Custom WebPart in Dev Environment i got error "Cannot import webpart". This is what I finally figured:
  1. Ensure your feature actually contains the correct version of webpart/assembly.
  2. Ensure safecontrol is correctly defined with correct version
  3. Now, Delete all your solution related webparts from the webpart gallery. (This is what really helped me). You can use a ps script for that.
  4. Redeploy solution. (This will activate the features, but not add the webparts to webpart gallery).
  5. Deactivate the webpart feature either via UI or Disable-SPFeature command (i used ps)
  6. Activate the webpart feature (Enable-SPFeature). This will bring all the new updated webparts to the web part gallery.
  7. Check if the trust level in your web.config file is set to “WSS_Minimal” ? If so, you will have to set it to “medium” as follows:
    <trust level="WSS_Medium" originUrl="" />
The above is especially useful if you change your classname, namespace or versions. Now I was able to import the webpart fine. I also found this method is consistent. So I added the Delete webparts and Disable, Enable features as part of my deployment script.

Monday, October 3, 2011

Debugging Custom SharePoint Timer Jobs


SharePoint timer jobs are tasks executed on a scheduled basis by the Windows SharePoint Services timer service (owstimer.exe). They are analogous to scheduled tasks, and you can create them in any version of Windows, but SharePoint timer jobs come with many more benefits. SharePoint relies on timer jobs for a number of its functionality areas, and you can even broaden those functionalities and create your custom timer job to introduce new features.

For instance, last month I developed a custom timer job that runs on a daily basis to query all the SharePoint lists and libraries in all the site collections and insert corresponding records into a custom database table for reporting purposes.
Unfortunately, SharePoint timer jobs are tricky when it comes to debugging; it is not about attaching a debugger to w3wp.exe like what we did earlier in this issue. Troubleshooting my custom timer jobs has caused me a lot of headache; that is why I am determined to share with you all the tricks that I have learned in the course of developing a reporting timer job.
To debug custom timer jobs, follow these steps:
  1. Insert an always-failing assertion statement at the beginning of the Execute method. You should use Debug.Assert(false) rather than Trace.Assert(false) since debug calls are detached from the release builds; then you don’t have to remove them from your code before moving to staging or production. 
  2. Every time the timer job starts, you will get a pop-up window. This window hinders the execution of the timer job until you close the message box. Note that timer jobs run in parallel, so this window will never halt the execution of other timer jobs running simultaneously. For now, leave this window alone.
  3. Select Debug > Attach to Process, and attach a debugger to the Windows SharePoint timer service (owstimer.exe). Make sure that the “Show process from all users” checkbox is selected if owstimer.exe is not listed.
  4. Click the Ignore button in the assertion window.
There you go!

You might be wondering why you should insert the assert statement at the beginning of the Execute method of the timer job. It is true that you can just attach a debugger to owstimer.exe and wait for the subsequent cycle of the timer job, but it could be tough to find out whether the application has been effectively attached to the process since the jobs may not fire for several minutes. You could be left with Visual Studio attached to the owstimer.exe process with breakpoints set and wondering whether the job is running or wondering whether the breakpoints are not being hit because of some problem with loading the symbol files.

Saturday, October 1, 2011

New Features and Enhancements in SharePoint 2010



Microsoft has launched SharePoint Server 2010 which includes a lot of enhancements, fixes, and news features as compared to SharePoint Server 2007.
1. New User Interface including Ribbon
User Interface is changed a lot in SharePoint 2010 and now you will be able to do more with few clicks. There are a lot of changes in the User Interface like, "Site Actions" menu is moved to left side of the page, some new options has been added in the "Site Actions" menu, the overall look and feel of the site is different as compared to SharePoint 2007, asynchronous user interface using AJAX and SilverLight which leads to minimal postbacks and improved performance of the site.
But the biggest change in the User Interface of SharePoint 2010 is the addition of Ribbon UI. Microsoft has earlier introduced the Ribbon UI with Office 2007. Now the same Ribbon UI is available in the SharePoint 2010 which brings the SharePoint user experience much more aligned with other office applications. You can see the Ribbon in the top area of any page in the SharePoint 2010 website, see the below screenshot.


Ribbon provides users access to various operations they can choose from. The Ribbon changes automatically for edit mode and view mode of a page. Ribbon also changes depending on what you are looking, like if you open a document library it displays document library related operations together with other common operations.
2. Built-in SilverLight Support
SharePoint 2010 allows adding SilverLight components without any additional configuration. First you will need to upload your SilverLight XAP file into a document library, then add SharePoint's OOTB SilverLight web part on a page and point it to the respective XAP file uploaded in the document library, that's it; SilverLight XAP component will be successfully added and displayed in the page.
3. Rich and Improved Theming Support
SharePoint 2010 provides built-in office-style themes just like in Word and PowerPoint. You can choose and apply a theme to change the look and feel of the web site as per the selected theme. You can also preview a theme on the web site before applying it. You can also imports themes from Microsoft PowerPoint. You can also create custom themes for SharePoint 2010 websites.
4. Multiple Browser Support
SharePoint 2010 supports Internet Explorer 7/8, Firefox, and Safari. But it will not support Internet Explorer 6.0 or less any more. Also there is no official news about its support for Chrome and Opera.
5. Rich Media support and Digital Asset Management
SharePoint 2010 offers Rich Media capabilities out-of-the-box and makes it very easy for users to share videos, audio, pictures, and other rich media files. A new asset library has been introduced in SharePoint Server 2010 which is specially designed to manage and share digital assets like video, audio, pictures, and other rich media files. Couple of web parts and controls has been also added to streamline the Digital Asset Management capabilities.
6. SharePoint Workspace
Microsoft Office Groove has been renamed to SharePoint Workspace in SharePoint 2010. SharePoint Workspace provides local and offline read-write access to SharePoint lists and libraries and also incorporates offline-online synchronizations. SharePoint Workspace is not only got new name but also a lot of new functions and better design.
7. Sandboxed Solutions
If you remember, in SharePoint 2007 all the solutions (.WSP) runs with full trust which requires farm administrators to pitch in and deploy the solutions. Also the solutions can be deployed at the minimum at a web application level. It means if a solution is deployed in a web application, it will be applicable for all the site collections available in that web application.
In SharePoint 2010, Sandboxed Solutions also called as User Solutions, is a new concept which addresses the above issue by allowing site collection administrators to deploy solutions at the site collection level which is safe to run and not affect the other site collections and web applications running on the same farm. Farm administrators can monitor sandboxed solutions and place restrictions on the resources, such as memory and CPU cycles, they can use. Sandboxed Solutions does not cover full SharePoint object model but it addresses the key scenarios like custom web parts and event receivers.
The solution deployment as in SharePoint 2007 is still exists in SharePoint 2010 but those solutions are called as Farm solutions.
8. Stsadm command-line tool is superseded by Windows PowerShell 2.0
In SharePoint 2010, the Stsadm command-line tool has been deprecated and it will be superseded by Windows PowerShell 2.0. SharePoint 2010 will still support the Stsadm command-line tool for backward compatibility with previous product versions. But it is recommended to use Windows PowerShell 2.0 when performing command-line administrative tasks.
9. Redesigned Central Administration web site
Central Administration web site has been redesigned in SharePoint Server 2010 to provide a better user experince and make it easier for administrators to find what they are looking for. The home page for Central Administration groups major functional areas (for example - Application Management, Monitoring, Security, and so on) together and lists many of the most commonly used tasks under each area. The Central Administration web site is also eqquiped with Ribbon UI which makes it easier for administrators to view or change details by making common configuration options a single click away.
10. Shared Service Provider (SSP) is no more exists
In SharePoint 2010, Shared Service Providers (SSP's) are no more available. SSP's have been replaced by Service Applications in SharePoint 2010. Earlier in SharePoint 2007, all services were combined into a SSP. Now is SharePoint 2010, all services are running as independent Service Application. You can select and configure from available services to run on an application server. You can also select and configure only required services for a particular web application.
11. New Hardware and Software requirements
SharePoint 2010 will ship only as a 64-bit product. So if you are planning to upgrade SharePoint 2007 into SharePoint 2010 and if you have deployed your SharePoint 2007 site into 32-bit environment then it's definitely a consideration to do the upgradation.
In addition to new hardware requirements, SharePoint 2010 will require an x64 edition of either Windows Server 2008 or Server 2008 R2. It also requires a 64-bit version of Microsoft SQL Server 2008 or SQL Server 2005.
12. Business Connectivity Services (BCS)
Business Connectivity Services (BCS) provides read/write access to external data from line-of-business (LOB) systems, web services, databases, and other external systems within Microsoft SharePoint 2010. If you have worked on SharePoint 2007 (MOSS 2007), you must be aware of Business Data Catalog (BDC). In SharePoint 2010, Business Data Catalog has been replaced by Business Connectivity Services.
Business Connectivity Services supports all the features provided by Business Data Catalog together with a lot of new features and capabilities. Following are some of the new features of Business Connectivity Services:
· Using BCS, you can read and write back to external systems from SharePoint 2010 site. Using BDC in SharePoint 2007 site, you were able to read data from external system but it didn't support to write back to external system.
· BCS supports cache-based and offline work features. Now users can manipulate external data when they are working offline and all the read/write operations performed against cached external data are synchronized when connection to the server becomes available.
· BCS supports reading binary large object (BLOB) data from the external system.
· Enhanced object model and APIs which enables developers to write generic applications to work against any external system.
· BCS provides batch and bulk operation support. So now it is possible to read multiple items in a single call which reduces the round trips to the external systems significantly.
· External data can be converted to a list like view very easily using External Lists.
13. Visio Services
SharePoint 2010 is equipped with Visio Services which allow you to share data linked diagrams in real time. Using Visio Services you can connect to backend, visualize the data and publish the Visio diagram into your SharePoint site. Visio data diagrams can be rendered without the need for Visio on the client computer.
14. New and enhanced SharePoint Designer 2010
To work with SharePoint 2010, Microsoft has also introduced a new version of SharePoint Designer called as "SharePoint Designer 2010". Following are some of the new features and capabilities introduced in SharePoint Designer 2010:
· Improved User Interface together with Ribbon which improves its usability and make it consistent with the UI of SharePoint 2010 and other office applications.
· Quick Launch Navigator and Site Content Structure for Site information
· Using Site Content Structure, you can create a: Web Part page, Master Page, list, and workflow
· Permissions can be set for individual users
· Saving and deleting site templates is now possible
· Ability to use XSLT List View Web Parts to show dynamic views of your data
· Support for attaching workflows to content types
· Support for workflow templates
· Create Content Types and attach to lists
· New concept of "Entities" which provides seamless integration with back-end systems
15. SharePoint Best Practices Analyzer
SharePoint 2010 is equipped with SharePoint Best Practices Analyzer which provides Microsoft's guidance for SharePoint implementation and troubleshooting and creates detailed reports to help administrators achieve greater performance, scalability, and uptime. A Problems and Solutions page in the analyzer helps you solve common implementation problems.
16. Usage Reporting and Logging
SharePoint 2010 includes a new database designed to support usage reporting and logging. The name of the database it creates is "WSS_Logging". SharePoint 2010 keeps tracks of everything it does by logging into the WSS_Logging Database. If you remember in SharePoint 2007, Microsoft has recommended to not access any SharePoint database directly. But in SharePoint 2010, the logging database is the only database that Microsoft will be happy to let the developers directly read, query and build custom reports against it.
17. Developer Dashboard
Developer dashboard is a new feature introduced in SharePoint 2010 which displays the performance and tracing information in the bottom of every page. Developers can use this information to debug and troubleshoot issues with page rendering time. By default this feature is disabled, but we can enable this feature in the development environments to get this additional information.
18. New SharePoint Developer Tools in Visual Studio 2010
Microsoft has introduced a new set of tools within the Visual Studio 2010 which make developing SharePoint applications as easy as any other .net applications. The new tools include project templates for many of the SharePoint application types, such as Web Parts, List definitions, Modules, Application Pages, Workflows, user Controls and others. A great feature in Visual Studio 2010 is the Visual Web part Designer. Now you don't need to build tables for layout, you can just drag and drop and create controls within web parts, similar to ASP.Net forms and user controls.
19. Client Object Model
The Client Object Model (OM) is a new programming interface for SharePoint 2010 where code runs on a user’s client machine against a local object model and interacts with data on the SharePoint Server. Client OM methods can be called from JavaScript, .NET code or Silverlight code and makes building rich client applications for SharePoint easy.
20. Language Integrated Query (LINQ) for SharePoint
Now in SharePoint 2010, you can use Language Integrated Query (LINQ) objects to query SharePoint lists. Earlier in SharePoint 2007 (MOSS 2007), using CAML queries was the only way to query SharePoint lists.
21. Improved Enterprise Search
SharePoint 2010 offers several new ways to customize and extend enterprise search capabilities. SharePoint 2010 provides following two main enterprise search options:
· SharePoint Server 2010 Search – the out-of-the-box SharePoint search for enterprise deployments included by default with SharePoint 2010.
· FAST Search Server 2010 for SharePoint – a brand new add-on product based on the FAST search technology that combines the best of FAST’s high-end search capabilities with the best of SharePoint.
Following are some of the new and enhanced capabilities introduced in the Enterprise Search area:
· New Custom Ranking Models allow you to change the weights that are used by SharePoint Search to rank results. Custom Ranking Models are used in conjunction with the Core Results web part.
· You can scale out the number of crawl/indexer components by adding additional servers to the farm and configuring them as crawlers which enables to increase crawl frequency, volume, and performance by distributing the crawl load among several servers, along with providing indexer redundancy if a server fails.
· SharePoint 2010 has capability to integrate FAST Search Server 2010 seamlessly.
· SharePoint 2010 supports wildcard search.
· Suggestions while typing search queries
· Improved "did you mean" suggestions togethor with suggestions for related searches.
· Faceted search is another new feature in SharePoint Search 2010. When a search query returns a lot of results the faceted search functionality displays a refinement panel on the left side which can be used to refine the results based on criteria like Result type, Site, Author, Modified Date, Tags, etc.
· Phonetic name matching and nickname matching - Users can search for a person by name without knowing the exact spelling of the name. For example, the search query "John Steal" could yield "John Steele" in the search results; results for the search query "Jeff" include names that contain "Geoff." In addition, nickname matching makes it possible for a search query for "Bill" to yield results that include "William."
22. New and improved Social Features
As you know the previous version of SharePoint (MOSS 2007) lacked on some of the main social features and developers needed to develop their own components to implement social features on top of SharePoint 2007. But now Microsoft has filled that gap in SharePoint 2010.
Following are some of the main social features introduced in SharePoint 2010:
· Tags, Notes, and "I Like It" - Now in SharePoint 2010, a user can add tags and notes with any page which can be either public or private. A user can also mark a page if he/she liked that page. SharePoint 2010 adds two icons "I Like It" and "Tags & Notes" in all the pages to provide this functionality.
· Ratings - SharePoint 2010 allows users to rate items within SharePoint site, such as ratings various items within Document libraries, custom lists, blog posts, discussions threads, etc.
· Tag Cloud - SharePoint 2010 includes an out-of-the-box tag cloud which can be added to any page within the SharePoint site.
· Newsfeed - Newsfeed is another features included in the SharePoint 2010. You can set the types of updates you want to get in your newsfeed. You can set this using the out-of-the-box settings section available within the user profile page.
23. New Claims-Based Authentication Model
SharePoint Foundation 2010 incorporates a new authentication model that works with any corporate identity system, including Active Directory Domain Services, LDAP-based directories, application-specific databases, and user-centric identity models.
24. SharePoint Health Analyzer
SharePoint Health Analyzer is a feature included in the SharePoint 2010 that allows administrators to schedule regular, automatic checks for potential configuration, performance, and usage problems in the server farm. Any errors that SharePoint Health Analyzer finds are identified in status reports that are made available to farm administrators in Central Administration. Status reports that are produced by SharePoint Health Analyzer explain each issue, list the servers where the problem exists, and outline the steps that an administrator can take to treat the problem. In some cases, errors are repaired automatically as soon as they are found, and it also informs farm administrators about the repairs done.
25. Multi-Tenant Hosting
SharePoint 2010 has capabilities for Multi-Tenant Hosting which allows to setup hosting on site collection level. Now you can host customer1 (tenant 1) on a site collection and customer2 (tenant 2) on another site collection within same web application. Each tenant will only have administrator access to his/her site collection. Also, service applications will keep each tenants data separate from another tenants. For example, one shared search service application will service tenant1/site collection 1's data and tenant2/site collection 2's data while keeping them separate from each other.
 Thanks to Vivek Jagga for his great Article.
Happy SharePoint...