Monday, July 15, 2013

Filtering XSLT List view webpart with Multiple SharePoint List filter webparts

Applies to SharePoint 2013
Here I am going to be using Empty Dataview webpart which is really DataFormWebpart.

Create a new Page in SharePoint Designer

Open in Advanced mode and attach a master page to it

image

Add the text for content holder

image

Insert a webpart zone and add 2 SharePoint List Filter webparts with in the zone.

image

Lets configure the 2 SharePoint list filter webparts to point to First Name and Last Name columns of the Contact List. This is done better in the Brower, so run the page by clicking the preview button

image

Edit the page in the browser and configure the list filter webparts like below

image

Configure the first filter to look like this

image

Configure the second Filter Webpart to point to Last name.

Now Drop an Empty DataView webpart

image

Then drop a datasource , In my case I am selecting the ContactsList as the datasource. Drop it between the datasource tags in the dataview.

image

Select the Column that you want from the DataSource Details view and insert them as Multi Item view.

image

The XSLT code is going to explode since this action adds a lot of XSLT to the page.

Now we have 2 SharePoint list filters and a dataview on the page. Let’s go ahead and connect them. Just like in the post before we are going to first create two parameters on the DataView one for First Name, another one for Last name. Then create a filter on the Dataview and pass values from these parameters to the firstname and the last name columns.

Creating parameters

image

Applying filter on these parameters

image

Connecting the 2 filter webparts to these Dataview

with the cursor on the DAtaFormWebpart tag click on the add connection and select “Get Parameter From” since we are tell dataview where to get the parameters from.
image

Lets configure the filter webpart connections to pass values to the Dataview. This can be done both in the Browser and the Designer, I prefer to do it form the designer. BUT MAKE SURE YOU REFRESH THE PAGE IN THE DESIGNER , or it will have an older copy of the code i.e code from before the filter webparts are configured. Better to close and reopen the page in designer.

Clicking on the dataform webpart tag click on the “Add Connections” button

image

image

image

 

Map the Filter to the parameter which will receive its value

image

Hit on next and click on Finish.

Now do the Same for the Last Name i.e connect Last Name filter to Param_LastName parameter.

And now run the page and you will see that when you filter the first name and the last name the dataview below filters as well. And it does the filtering instantaneously.

image

 

 

Check out my below posts on DataView Webpart, leave me a comment if you find them useful  

Using Dataview Webpart with SharePoint 2013
Difference between XsltListview webpart VS DataFormwebpart
Filtering XSLT List view web part with Text filter Web parts

Filtering XSLT List view webpart with Multiple SharePoint List filter webparts

Using Apply Filter Button webpart with multiple Filter webparts
Clearing filter selection on a DataView created by Filter Webparts

Filtering XSLT List view web part with Text filter Web parts

Applies to SharePoint 2013
Out of the several different filter webparts let’s try using a Text filter webpart

On a new non-webpart page created form designer add a dataview webpart and select a list

image

Select a Text Filter webpart

image

Change the filter name and Title name to something simple

image

We are going to create a filter on Lastname, the dataview webpart will display all the contact that contain this last name. High level strategry to achive this is to create a lastname parameter in DataView webpart, apply filtering based on lastname in the XSLT listview webpart and finally pass the value of this parameter from the list filter webpart. Lets start with creating a parameter in the xsltlistview webpart ,

image

Applied filter using this parameter

image

This will add the following CAML query to the Query section, before applying the filter it was only <Query/>

image

Now lets connect xslt listview webpart with text filter. With cursor in Contact List XSLTListview webpart click on ‘Add Connection’ and in the wizard select “Get Parameters From”, this basically means we are going to get the value of a Contact List parameter, the name of the parameter will be specified later in the wizard.

image

Hit on Next

image

Hit Next, select the text filter and select the action as send value to ,

image

Hit on Next to map the parameter of ContactsList (specified in the rt side of below image) to the name of the filter which is “Last Name” also( specified in left side).

image

finally hit on next and Finish

image

This basically adds the below spwebpartconnection to the page specifying the connection between the two webparts

image

Preview the page, type in the last name filter and you will see the values refresh in the XSLTListView in the bottom.

image

 

 

Check out my below posts on DataView Webpart, leave me a comment if you find them useful  

Using Dataview Webpart with SharePoint 2013
Difference between XsltListview webpart VS DataFormwebpart
Filtering XSLT List view web part with Text filter Web parts

Filtering XSLT List view webpart with Multiple SharePoint List filter webparts

Using Apply Filter Button webpart with multiple Filter webparts
Clearing filter selection on a DataView created by Filter Webparts

Using Dataview Webpart with SharePoint 2013

Using Dataview Webpart with SharePoint 2013

Let’s go ahead and use a DataView webpart and discuss some of the basic options that it provides.

Open SharePoint Designer 2013, connect to your site and create a new non-webpart page by clicking on New ASPX page in the folder in which you want to create the page.

image

Open the page in Advanced Mode by rt. clicking on it

Save the page, this is a good practice if not a lot of ribbon buttons are disabled. Keep doing this with any mods to the pages. Dataview webpart needs a webpart zone to render, drop a Webpart zone on it in between the form tags

image

After saving the page, go to the webpart zone tag and WebPartPages:WebPartZone and add DataViewWebpart

image

Vola! This has added the dataview webpart to the page, which is basically a lot of XSLT which we will go over very soon. Preview the page in the brower by clicking on the preview button.

image

 

Check out my below posts on DataView Webpart, leave me a comment if you find them useful  

Using Dataview Webpart with SharePoint 2013
Difference between XsltListview webpart VS DataFormwebpart
Filtering XSLT List view web part with Text filter Web parts

Filtering XSLT List view webpart with Multiple SharePoint List filter webparts

Using Apply Filter Button webpart with multiple Filter webparts
Clearing filter selection on a DataView created by Filter Webparts

Monday, August 22, 2011

Force FBA users to download word document instead of having them open in MS Word

FBA users when opening documents get either prompted with login or MS Word opens up the document and it is either blank or just a new document.

Way i found round this problem is to force them to download the document by going to Central Admin \ Select webapplication\ Authentication provider\ Set Enable Client integration to No.



Wednesday, August 17, 2011

Anonymous user gets prompted to view list items even through they have view list item permissions

In a publishing site even if anonymous users have been granted permission on all the level i.e in Central admin, in Site and if permissions are broken then in List\ Libraries but still they get prompted to enter username\ password to view the list\ list items.

To fix this issue deactivate a hidden feature by name ViewFormPagesLockDown, this feature when active denies access to anonymous users to all pages of type "application pages" by prompting authenication.

Below is the command to deactivate it, after deactivating it turn off\ on anonymous authentication on all the 3 level i.e
in CA for the webapplication,
in Site collection and
finally in any lists that you have broken permissions.

stsadm -o deactivatefeature -url http://yourserver -filename ViewFormPagesLockDown\feature.xml

Below is a MS link to configure anonymous access in sharepoint.
http://office.microsoft.com/en-us/sharepoint-server-help/grant-permissions-to-anonymous-users-HA101805390.aspx

Friday, August 5, 2011

Converting a site to a Site collection

Creating a site collection from site











1. Below I am creating a new database, since my site is a publishing site I will be creating a blank publishing site.


create new site in its own DB using the below cmstemplate


a. $w=Get-SPWebApplication("http://shareptapptest:9002")






b. New-SPContentDatabase "WSS_Content_Internet_Hosted_Sites_3" -DatabaseServer "shareptDBtest" -WebApplication $w






c. new site : here I am creating a blank publishing template which cannot be created from UI


New-SPSite http://shareptapptest:9002/hostedsites -OwnerAlias testdomain\testadmin -Name "SITENAME" -Template "cmspublishing#0"










2. Export the site http://shareptapptest/hostedsites/SUBSITE :






stsadm -o export -url http://shareptapptest/hostedsites/SUBSITE -filename "C:\Deployments\Release2-Technical Upgrade\SUBSITE06142011.bak"






3. Makig sure all site collection and sub site features\ spolutions are activated on the new site collection


a. Make sure all solutions are activated for this site collection as well.






b. Or what you can do is also make sure that all the features that are activated on the source are activated on this site collection as well.






4. Import the exported data using the below command.






stsadm -o import -url http://shareptapptest:9002/Hostedsites -filename "C:\Deployments\Release2-Technical Upgrade\SUBSITE06142011.bak"






5. Potential Issues :


a. when i tried to run the website it bombed out becuase i think it could not find the master page.


b. The master gallery exists only on the site collection level so a site might be pointing to the site collection;s master page in which case when it is exported out the master page will not be exported.


c. Also the publishing images library which is “images” is usually in the stie collection so all images pointing to this will not be visible.






6. to copy the MASTER PAGE : Open 2 instances of SPD , 1 for each website, Copy the master pages from SUBSITE using Sharepoint Designer, copy the 2 master pages from the "MAster PAges"










7. This is used to fix the page layout, if you see the layout of the pages in the document library in SP Designer you will see that the page layout is still pointing to the old server;s pagelayout. Below command will fix the page layout


a. install gary extensions using the below commands


i. Download them from the internet, do a search for Gary Lapointe extensions and you will find them.






Add-SPSolution C:\Deployments\Release2-Technical Upgrade\Lapointe.SharePoint2010.Automation.wsp


Install-SPSolution -Identity Lapointe.SharePoint2010.Automation.wsp -GACDeployment






stsadm -o gl-repairsitecollectionimportedfromsubsite -sourceurl http://mossappdev10:9006/hostedsites/chphc -targeturl http://mossappdev10:9005/hostedsites










OR


Of what you can do is that instead of installingand running these commands, in SPD Deattach and Reattach the page layout and if it refers to the pagelayout on the same server then it is fixed.
8. For any images missing fix the hardcoded references to this SITE when it was the subsite.



Friday, July 15, 2011

LinQ to SharePoint examples

Namespaces to refer in Visual studio for using LinQ

using System.Linq;
using Microsoft.SharePoint.Linq;
using System.Collections.Generic;

Generate Entity classes using SPMetal
Run the following command to generate it
spmetal /web:http:// /code:

Creating a Join between two list UserAccounts and Invoices.
List UserAccounts have Account, Name
List Invoices have Account, Amount, Paid

//First refer the Datacontext class
XDataContext a = new XDataContext(SPContext.Current.Web.Url);


//Refere the Lists and create entityLists out of them

EntityList Invoices = a.GetList("Invoices") ;
EntityList UserAccounts = a.GetList("UserAccounts");

//need to do a join from the two lists and bring them together.
//use the ToList() on the list in the from to avoid getting errors due to inefficient CAML queries. with this method it retrives data from the list instantaniously.

var query=
(from u in UserAccounts.ToList()
join i in Invoices on u.Account equals i.Account
where int.Parse(u.Account.ToString()) > 1001 && int.Parse(u.Title.ToString()) < 10010
select new { u.Name, u.Account, i.Amount, i.Paid }) ;

//make this as the datasource.GridView1.DataSource = query;
GridView1.DataBind();


Inserting in Lists using LinQ

XDataContext a = new XDataContext(SPContext.Current.Web.Url);

EntityList Invoices = a.GetList("Invoices");

int count = 0;
//get the count of the records
count =
(from x in Invoices
select x).Count();

List ic = new List();

if (count == 0)
{
    //insert 5K records
    for (int i = 0; i < 300; i++)
   {
       //create records and store them in a system.collection.generic.list collection
       InvoicesItem inv = new InvoicesItem() { Account = "100" + i.ToString(), Amount = 100 + i, Paid = check(i) };
        ic.Add(inv);
   }

//insert all of them in shot
Invoices.InsertAllOnSubmit(ic);
a.SubmitChanges();
}

//here is the check function that is being used
private Boolean check(int i)

{
if (i % 2 == 0)
return false;
else
return true;
}