|
|||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionA few weeks ago I was asked to prepare a list of employees working in different departments, but summarized in one head-departement. This list should reside on a Webpart-page of the head-department. The layout should be in many parts different from the standard-layout which People Search Core Result (PSCR) gives and it should fight against some limits that are build into PSCR. These limits are:
Additionally I have some other restrictions which, I think, many normal users in bigger, productive MOSS 2007-environemts have:
But fortunately I'm allowed to use Microsoft's Office SharePoint Designer 2007 and I have a fair knowledge of SQL, XML and XSLT! I've divided this article into two parts becasue of my little spare time for writing it. This first part gives you directions on how to get the data with the help of SharePoint's webservices. The second part (coming soon) will provide you with some enhanced XSLT to format, page and group these data. BackgroundAfter many trials to tune PSCR getting my wishes done, I decided that the only way to get arround the hardest limit, the 50 records per roundtrip, is to use a very basic, but always available webpart: Using the DataFormWebPart to retrieve People-InformationDataFormWebPart can retrieve data from various A valid parameter-XML looks something like this: <QueryPacket xmlns="urn:Microsoft.Search.Query" Revision="1000">
<Query>
<Context>
<QueryText language="en-US" type="MSSQLFT">SELECT PreferredName, Department, Manager, AboutMe,
Title, Path, Description, Write, Rank, Size FROM SCOPE() where "scope"='People'
AND Department LIKE 'MAN DEP 1'</QueryText>
</Context>
<Range>
<StartAt>1</StartAt>
<Count>1000</Count>
</Range>
</Query>
</QueryPacket>
A detailed description of the QueryPacket-syntax can be found here:http://msdn.microsoft.com/en-us/library/ms563775.aspx Most interesting in this context is the <QueryText>-element: The attribute type="MSSQLFT" means that this a a "Microsoft SQL Full Text"-Query. So it is somewhat like SQL, but also somewhat different:
Also interesting is the <Range>-element: <Start> determines from which position on the result will be returned; <Count> gives the number of results returned. My hardest limit and my motivation for doing this work was the "50-record per roundtrip"-limit; so here we can bypass that limit. It's up to you to make this number a high a you like; the default is 100. Seeing the result-dataBut some questions will arise now to you:
1) The query returns XML (Surprised? - No, not really). This makes absolutly sense, because then we can render it by using XSLT. 2) A list of properties supported by your Shared Service Provider / MOSS 2007 can be obtained by another method of the same webservice: GetSearchMetaData (see below on how to view also these information on a SharePoint weppart-page) 3) Yeah, this is the most "frustrating" part in it, because IMO SharePoint Designer doesn't support this kind of work very well! But it works.
Because most times I want first to have the data and afterwards I pay attention to the formatting, I used this XSLT whereever I wanted to see what comes back from my query (see file ShowAllXML.xslt): <?xml version="1.0" encoding="utf-8"?>D
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp>
<xsl:copy-of select="*"/>
</xmp>
</xsl:template>
</xsl:stylesheet>
This XSL just takes the input XML and render it back like XML; xsl:copy-of select="*" takes every node in the XML and gives it back; the surrounding <xmp>-tags give the information to the browser, that it should be treated like text (and not like tags, because then we would only see the parts of the input-XML which are not tags). Inside SharePoint/MOSS 2007 XSL is used in the following way:
So, whenever you use now webservices inside your SharePoint-pages, use this simple XSL to first look what data you really get. And, another advantage: you can copy the rendered HTML, which is shown like XML, to your XSLT-tool as an input-file for testing the XSL. If you don't have any XSLT-tool, you can alos use Internet-Explorer's build-in XSLT-processing capability by referencing the XSLT-file (XSLTFileTableView.xslt in my example here) which IE shall use to show your XML: <?xml version="1.0" encoding="utf-8"?>
<!--Referencing the correct XSLT to use-->
<?xml-stylesheet type="text/xsl" href="XSLTFileTableView.xslt"?>
<All_Results>
....Rest of your XML...
</All_Results>
So, where are we now? What's missing: Properties for the MSSQLFTAs mentioned above, the webservice-method GetSearchMetaData gives the information about the available properties for the QueryEx-method. So just put another DataFormWebPart to your search-page (or create a nwe page and insert it there), create a new connection to the search.asmx of your site and now use the GetSearchMetaData instead of the QueryEx-method. Save the webpage, modify the webpart and copy the XSL of ShowAllXML.xslt (see above) into the XSL-editor of your webpart's properties. As a result you get an XML showing you the SearchMetaData of your site. Each managed property is one of these elements: ...
<Properties diffgr:id="Properties68" msdata:rowOrder="67" diffgr:hasChanges="inserted">
<Name>Manager</Name>
<Description />
<Type>System.String</Type>
<Retrievable>true</Retrievable>
<FullTextQueriable>false</FullTextQueriable>
</Properties>
...
The <name>-element gives you the name that you can use in your MSSQLFT-query of the QueryEx. I cannot provide you a full list of the properties because they are dynamically / configurable on the SharePoint-Shared Service Provider. What I've mentioned in our environment is, that for the people-properties which shall be exposed to the query-service, there is a need for indexing them. So if you're missing a property in your list, the chance is good to ask your SharePoint-admin to set the property to "indexed" in the people-import properties of the Shared Service Provider (your admin will know where to find it :-) ) The list of properties may be horrible long and may miss descriptions. So you will have to filter them somehow. Becasue I hate to copy&paste the names out of the XML into the QueryEx-Expression-XML, I did the following:
Take care of the following when using this:
So you should now have the wished people-records with the properties you want in XML-format, and NOT limitted to 50 records. HistoryThis is the first version of this article.
|
||||||||||||||||||||||||||||||||||||||||