Solved

Cannot sort list with custom webpart in SharePoint 2007

Posted on 2010-09-21
17
868 Views
Last Modified: 2012-05-10
Following instructions on MicroSoft site,Utube, to filter and sort a webpart, I have been able to filter the list per condition, but cannot sort the list.  When I modify the QueryOverride line as follows: "<property name="QueryOverride" type="string"><![CDATA[<Where><Eq><FieldRef Name="Status" /><Value Type="Text">Active</Value></Eq></Where>]]></property>", I get the list of projects in my webpart.  When I change this line to, "<property name="QueryOverride" type="string"><![CDATA[<Where><Eq><FieldRef Name="Status" /><Value Type="Text">Active</Value></Eq></Where><OrderBy><FieldRef Name="PID" Nullable="True" Type="Text" Ascending="FALSE"/></OrderBy>]]></property>", I get "This query has returned no items. To configure the query for this Web Part, open the tool pane."  (Attaching webpart html.)  Why doesn't SharePoint get anything returned with my new QueryOverrider statement?  Is this the best place in the html of the code to do the sort.  (I have another related question on displaying multible columns, but I will ask that in a new question.)

Active-Projects-4.txt
0
Comment
Question by:twseeman
  • 9
  • 8
17 Comments
 
LVL 7

Accepted Solution

by:
EagleUK earned 500 total points
ID: 33757955
In an example on MSDN, there is a space between Ascending="FALSE" and the trailing /> tag. Have you tried this?

I also found a reference to this problem where they removed the line breaks and placed the entire QueryOverride statement on one line to fix it, so you might try that.

See:
http://stackoverflow.com/questions/2524026/content-query-web-part-how-do-you-orderby-when-you-queryoverride

Good luck!

0
 

Author Comment

by:twseeman
ID: 33758207
Thanks for the suggestion.  I added the space and it didn't change.  Actually, I previously put the code on one line and that did allow the where cause to work.  As soon as I add the OrderBy part I either get "There is a problem with the query that this Web Part is issuing. Check the configuration of this Web Part and try again." or the error above saying the query returned no data.  I also checked the link you included, tried flipping the Where and OrderBy in the statement and it didn't help.
0
 

Author Comment

by:twseeman
ID: 33758272
I discovered that I can sort by a default date field, created or modified.  I just change the FieldRef Name to either one of these and then set Type="Date" and I get a sorted list by created or modified.  So the questions are, is the type "Text" correct or is there a reason I cannot sort on PID, which is my alphnumeric 8 digit project ID.
Thanks
Tom
0
 
LVL 7

Expert Comment

by:EagleUK
ID: 33759501
I tried creating a custom list with a PID field (8 character text) and a Status field (choice). I then displayed it as a ListView on the main page. Using the default AllItems view, I can sort on the PID field and filter on the Status field and everything seems to work OK.

I need to understand more about your custom web part. Is this a ListView, Content Query Web Part, etc?   How are you maintaining it (SPD, Visual Studio)?

0
 
LVL 7

Expert Comment

by:EagleUK
ID: 33759552
OK, I just took another look at your code and answered the first question (CQWP). Sorry, it's early here, must need more coffee...

Can you post the link to the MS article and the YouTube video that you referred to?

Thanks
0
 
LVL 7

Expert Comment

by:EagleUK
ID: 33763694
OK, I may have found the solution to your problem. Try deleting the web part from the page and web part gallery, after exporting it of course, and then re-upload it and add it to the page again. When I tried that, your QueryOverride tag started working, including the ORDER BY clause.

Fun stuff. Let me know if this works for you.
0
 

Author Comment

by:twseeman
ID: 33769777
Here is the utube link: http://www.youtube.com/watch?v=r2uMQ2XRTMk

I check my site setting and do not have a web parts gallery.  

 One additional piece of information on my implementation;  I created a page to add these web parts to.  I am using a site I have to track my projects and I am working to create a page that allows my users to view project and related information from two other list on my site.  My goal is to allow the user to choose a project and then see related information from these other list in a one to many relationship.  As I understand it, I cannot  use web connections because my list have custom fields.  I didn't use Visual Study, I am primarily working in SharePoint and SPD.  I did import from MS Access which may be why these list have custom fields in them.

Thanks
0
 
LVL 7

Expert Comment

by:EagleUK
ID: 33772803
I don't have access to my WSS server at the moment as I am travelling, but I believe that the Web Parts Gallery is in the top level site of your site collection. In Site Settings, the link to the top level site should be  on the right side of the page. On that page, you'll find the Web Parts Gallery.

At this point, you don't need to change the web part, just do an IISRESET on your SharePoint Server.

I understand that you have further requirements, but it will be easier if you attack one problem at a time.

Have you considered using Project Server?
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:twseeman
ID: 33773328
The problem is that I am not an admin on the SharePoint Server.  I will need to investigate who has this access and give that a try.
I have not considered using Project Server.  Would that interface with SharePoint or would that be a seperate platform.  I work for a large global company and I might be able to find an installation of Project Server on my corporate network if I look into it.  Are you suggesting that this would be an easier system to work with in my efforts to provide a customize interface with my users?  I am always open to options.  Sharepoint is proving to be a bit inflexible.  Thanks
0
 
LVL 7

Expert Comment

by:EagleUK
ID: 33776049
It's best if the server administrator can schedule a reset during non-duty hours/weekend. Ideally, you would be doing the development/testing on a separate server, not the production server.

Project Server is an application that runs on WSS and integrates with it. It is designed to provide the functions that you describe, but is neither easy nor cheap to implement. If your SharePoint farm has multiple front end servers, then you need to install Project Server on all of them.

You can connect web parts even if they have custom fields, BTW. I do this often with ListViews, but am not sure that ContentQuery Web Parts can also do this. Unfortunately, I won't be home until next week, so can't check this.

It would help me if you could post some screenshots of the list settings for the lists that you are attempting to connect, and also a screen shot of your main page content area so that I get a better idea of what you are trying to do.
0
 

Author Comment

by:twseeman
ID: 33779597
Responses:
1) I have opened up a ticket with my help desk to get the reset done and/or notify me when it is done.  I agree, I need to have a development local machine that is dedicated to dev.  I started working on this but ran into an issue.  I will need to get back to it and get it done.
2) I asked about Project Server and was told by my contact, that he didn't know if anyone was using it in our corp.  He suggested I open up a ticket with our help desk to ask.  I will do that.  It would result in a shift in my effort and probably delay my progress significantly.
3) I will look into ListViews.  I don't remember working with it yet.
4) I am attaching a zip file.  It will show you my Access view I am trying to duplicate.  It also has information on the three lists I am working with and several of the field information in those lists.  My big question is, what makes a field custom.  Also, what is it about my lists that makes them not selectable for connections.  I will need to look into ListViews you recommend.
Thanks for your time!
Projects-Screen-Shots.zip
0
 

Author Comment

by:twseeman
ID: 33780435
New information:  I checked my test page with the weparts.  I was able to connect my secondary lists to each other, but my main list, "projects", I attempt to setup up a connection from, all the options are greyed out and when I mouse over 'Get Sort/Filter From', I get a popup that says, "The coonection type 'Get Sort/Filter From' is not compatible with any other Web Parts on the page.  

So my question is, what is making my projects list non functional for connection.
Thanks
0
 
LVL 7

Assisted Solution

by:EagleUK
EagleUK earned 500 total points
ID: 33828728
I've been away on a training course, but will try to re-engage on this problem.

I had a look at your screenshots, and do not see a unique column in Projects list that you are using for a primary key. I had assumed that this was the PID field, but you have it marked as not required.

In any relational database, you have to have primary keys for each of the tables (lists) in order to link them. So, for the Projects list, you would make the PID the primary key, and then, in each of your secondary lists, you would refer to it when linking them together. In your Access screen shot, you can see that this is the case as each of the sub-records starts with the PID that they are associated with. This relationship has to be maintained in SharePoint or you won't be able to link them together.

Did you get the Sort on PID working in your CQWP? As I recall, you were arranging to get the IIS server reset.

Also, have you considered upgrading to SharePoint 2010? It has built in support for Access databases, and would probably make this whole process much easier.

A short 24-minute video:
http://channel9.msdn.com/shows/Access/Microsoft-Access-2010-Demo/
Access Blog:
http://blogs.msdn.com/b/access/archive/tags/2010+intro+series/default.aspx

Hope this helps...
0
 

Author Comment

by:twseeman
ID: 33836037
I will check into the design and make sure it is set to Required.  In my Access 2007 interface, I do have it check to make sure it is unique.  I will make sure it states required and uniquic in sharepoint and see if that make a difference.
We will be moving to SharePoint 2010, but I don't know when.  
I have not been able to get a reply from my help desk on doing the reset.  I will need to try again.
I'll let you know if I make progress with the change to PID field. Thanks
0
 

Author Comment

by:twseeman
ID: 33841286
I tried making the PID field required and that didn't make any difference.  I believe I will need to abandone this approach.  I just am not making any progress.  Thanks for you help.
0
 

Author Closing Comment

by:twseeman
ID: 33841337
I did make progress but I was unable to resolve issue.  I abandoning this approarch.
0
 
LVL 7

Expert Comment

by:EagleUK
ID: 33843831
I'm sorry that you were unable to resolve this. As I mentioned previously, I did duplicate the problem and was able to get the sort working after making the changes and resetting IIS, so I hope that works for you once the server is reset. For the linked web parts, it may be worth a try to start over on a new site and make the PID required from the start. You should be able to link the web parts by the PID field.

The good news is that, if you do move to SP2010, the Access Services may solve your problem anyway. Have a look at the links that I provided to get a better idea.

Good luck!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now