Friday, September 14, 2012

Powershell Script to Importing & Exporting sites in SharePoint 2010

SharePoint 2010 we can import and export sites, lists, document libraries and items using Export-SPWeb and Import-SPWeb.

Export-SPWeb http://SP/TeamSite –Path C:\Backup\website.bak

If we only want to export a list in a site you can use –ItemUrl parameter as shown below:

Export-SPWeb http://SP/TeamSite -ItemUrl “Lists/<<MyList>>” `
–Path C:\Backup\website.bak

We can use the Import-SPWeb cmdlet to import the exported files to SharePoint 2010.

Import-SPWeb http://SP/TeamSite –Path C:\Backup\website.bak


SSIS 2008 with Team Foundation Server 2010

Case
A lot of my clients are still working with SSIS 2008 (R2), but already have Team Foundation Server 2010 for source control. How can you connect to TFS 2010 with BIDS/Visual Studio 2008?

 http://microsoft-ssis.blogspot.com/2012/04/ssis-2008-with-team-foundation-server.html


Thanks to Microsoft for  this excellent workaround.

Monday, September 10, 2012

Access Denied error while trying to Preview TFS Added SSRS Report


Access Denied error while trying to Preview SSRS Repor

You might get a message "An error occurred during local report processing. Access Denied. (Exception from HRESULT: 0x80030005 (STG_E_ACCESSDENIED))" while you try to preview a report you developed under VS 2008 and which has been added to TFS or any source control.

The reason for this is due to the .data file associated to the report which is read only state. You can resolve this issue by either checking out the .data file or un-checking the read-only attribute of the file under local folder.


Here is a nice article post by about the issue

SSRS Grouping and Row Visibility


SSRS Grouping:

We can configure SSRS report Group On filter using configuration.

Step1: Create a Custom Parameter and give default and available values. (None and Filter1)

Step2: After adding Table to report design, add Parent Group and enter group expression as shown below.

=IIF(Parameters!GroupOn.Value = "Filter1",Fields!Filter1Name.Value,"")

Step3: Add this Group on top of the table and merge the fields.


SSRS Group Row Visibility:

Select the Group row and right click and select “Row Visibility” and end the expression as below.
This will configure the GroupOn filter row visibility.

If you select “None” then it will not show GroupOn Row; if you select Filter1, it will show GroupOn Row with Filter.Value.
=IIf(Parameters!GroupOn.Value="None",1=1,1=0)

Tuesday, September 4, 2012

Redirect from NewForm.aspx to DispForm.aspx or EditForm.aspx of newly created item


Redirect from NewForm.aspx to DispForm.aspx or EditForm.aspx of newly created item.

You may need to redirect from NewForm.aspx to DispForm.aspx (or other page) of newly created item when creating SharePointsolutions like Invoices and Orders management. There are a couple of blogs out there that already have a solution for this. Because at the moment of item creation there is no item ID yet all we can do is to redirect to other page where we can query SharePoint list using web services for the last created item by current user. Then we can just redirect to wanted page using queried item ID.

Thanks to SharePoint Drive team.

http://www.sharepointdrive.com/blog/redirect-from-newform-aspx-to-dispform-aspx-or-editform-aspx-of-newly-created-item/


HTTP Context:
http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/



USE THE BELOW CODE IN ITEM ADDING EVENT
Using
SPSite site = new SPSite(properties.SiteId))          
{
using (SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
 {
SPList list = web.Lists[properties.ListId];
DisableEventFiring();
SPListItem itemToAdd = properties.ListItem;
foreach (SPField field in itemToAdd.Fields)
{
if (!field.Hidden && !field.ReadOnlyField && field != null && field.InternalName != "Attachments")
{
if (properties.AfterProperties[field.InternalName] != "")
{
 itemToAdd[field.InternalName] = properties.AfterProperties[field.InternalName].ToString();                
           }
}
}
 itemToAdd.Update();
 EnableEventFiring();

// Redirect
SPUtility.Redirect("DispForm.aspx?ID=" + itemToAdd.ID, SPRedirectFlags.DoNotEndResponse, httpCurrentCtx);

 }