Apr
06
Filed Under (Search, Tools, Web Services) by Andy Diericks

For my current development, one of the requirements is to be able to make some search through the Moss API or web service, so after some search on the web I discovered a really nice tool.

The SharePoint Search Services Tool, which allow you to directly do your request on the web services.

That tool is really awesome!

image

Make a request on a web services consist on 4 steps:

Get the value and scope you want to search on, generate the "Query Packet", which is simply create an XML formatted to be understood by the web service, make the request to it (via Query or QueryEx method), get the answer.

With that tool you will be able to:

  • Define your query text
  • Define the sort method
  • Choose the properties to define in the XML answer
  • Query the Query or QueryEx methods
  • See the results in XML or in datagrid view

The request window:

image

The Links

Download the SharePoint Search Services Tool from Codeplex: http://www.codeplex.com/SharePointSearchServ

Visual How-To access to the SharePoint wseb services: http://msdn.microsoft.com/en-us/library/bb625950.aspx

The QueryPacket element on MSDN: http://msdn.microsoft.com/en-us/library/ms451565.aspx

 

 



Apr
05
Filed Under (Other) by Andy Diericks

I’ve discovered a funny thing when I was searching some information about EnableUrlSmashing (I love the name), Microsoft created in 2006, published in 2008, a patent about the search API in SharePoint.

That patent ("Simplified search interface for querying a relational database") covers the Query, KeyWordQuery class and more.

An extract from the abstract:

Methods and computer-readable media are provided for performing a search on a relational database. According to one method, a query class is provided that includes properties that specify how a query is to be performed and how results from the query are to be returned, and an execute method that is called to perform the actual query. A keyword query class derived from the query class is also provided that includes keyword query properties and an execute method for performing the keyword query.

Link to the full patent: http://www.freepatentsonline.com/y2008/0114745.html



No, the blog isn’t transformed into a warez board, that’s the real thing. ;-)

Since the 03/31/2009, you can freely download it directly from the microsoft site, link is below.

After the news about setting a part of the BI stack of Microsoft, PerformancePoint, for free to the enterprise CAL customers, it’s now the turn of the SPD 2007 to be free.

That will probably leverage again a bit higher the reasons to go for SharePoint for the futures customers.

LicenKeySPD2007

 

For the time being saying to  them:"Ok you’ve bought an expensive piece of software even if it’s a killer-app, now you have to buy for each of you’re developers or designers a new office 2007 licence".

The answer is rather often:"Oh, it’s not included in SharePoint or Visual Studio ?"

 

And now I’m waiting for Infopath for free ;-)

The download link:

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=baa3ad86-bfc1-4bd4-9812-d9e710d44f42



The code below will show you how to get all the groups which a user belongs to, through webservices using JavaScript.

That functionality isn’t provided OOB in Sharepoint 2007, but can be really useful when you get a lot of security groups and some issues about them. It can be used for auditing, debugging …

Here is an example:

The user enter the account "MYDOMAIN\MyAccount" click on the link and get:

  • Group Name: Group1
  • Group Decription: Description of Group1
  • Group Name:Group2
  • Group Decription:Description of Group2

 

Implementation

For doing it, I will use a JavaScript library, which is in fact a proxy class, which means that our code will be easier to write, maintain and debug, all the boring stuff are already done for you ;-)

Here is the link to the site of Darren which contain the library in the Download section. http://darrenjohnstone.net

Here is some examples http://darrenjohnstone.net/2008/07/22/examples-for-the-sharepoint-and-office-live-javascript-api/

To include the library in your Sharepoint site, please follow Darren’s advices:

If you have full control of your server:

1) Locate the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS folder.
2) In there create a new folder called JSAPI.
3) Place the extracted .js files in there.

If you don’t have full access:

1) Open SharePoint Designer and connect to your site.
2) Create a new folder called JSAPI at the root of the site.
3) Copy the extracted .js files to the folder by dragging them from Windows Explorer to SP Designer.

Where to put code ?

  • In a html file, and show it in a page viewer webpart or
  • Insert it in a page layout, or even master page.

 

Coding

First of all, you will need to make some include to be able to use the web proxy class:

   1: <script type="text/javascript" src="/_layouts/JSAPI/SPAPI_Core.js"></script>
   2: <script type="text/javascript" src="/_layouts/JSAPI/SPAPI_Lists.js"></script>
   3: <script type="text/javascript" src="/_layouts/JSAPI/SPAPI_UserGroup.js"></script>

 

We need to create a simple form, containing

  • A textbox: the user will type the username(with domain) in it.
  • A link: to start the job.
   1: <form method="post" action="">
   2: <input id="Text1" type="text" />
   3: <a href='#' onclick="javascript:start()">Start the search</a>
   4: </form>
   5: <div id="username_div"></div>    

 

And now the interesting part, I will shortly explain the JavaScript methods below:

  • Start: We get the user name from a textbox and call the getGroupCollection and Formatresult methods.
  • getGroupCollection: Receive the username by parameter. The method will use a SPAPI_UserGroup object and request the groups that the users belongs to, through the getGroupCollectionFromUser method. The result will be put in two arrays, the first containing the names of the groups, the second one containing the descriptions.
  • FormatResult: The arrays containing the groups names and descriptions are  parsed. The content is formatted in a more friendly way.

 

   1: <script type="text/javascript" language="javascript">    
   2:  
   3: function getGroupCollection(userName)
   4: {
   5:     var groupName = new Array();
   6:     var groupDescription = new Array();
   7:     var arrGroup = new Array(groupName,groupDescription);
   8:     
   9:     var userGroup = new SPAPI_UserGroup('');
  10:     var groupItems = userGroup.getGroupCollectionFromUser(userName)
  11:     
  12:     if (groupItems.status == 200)
  13:     {
  14:             var groupTags = groupItems.responseXML.getElementsByTagName('Group');
  15:     
  16:             for(var i=0;i<groupTags.length;i++)
  17:             {
  18:                 groupName.push(groupTags[i].getAttribute("Name"));        
  19:                 groupDescription.push(groupTags[i].getAttribute("Description"));        
  20:             }
  21:     }
  22:     return arrGroup;
  23: }
  24:  
  25: function formatResult(groups,username)
  26: {
  27:     var result=""; 
  28:     result = "The user " + username + " belongs to: </br>";
  29:     for(var i=0;i<groups.length;i++)
  30:     {        
  31:         result+= "<b>Group name: </b>" + groups[0][i] + "<br />";                       
  32:         result+= "<b>Group Description: </b>" + groups[1][i] + "<br /> <p> </p>";
  33:     }
  34:  
  35: return result;
  36: }
  37:  
  38: function start()
  39: {
  40:     var userName = document.getElementById('Text1').value;
  41:     var groups = getGroupCollection(userName);
  42:     document.getElementById('username_div').innerHTML = formatResult(groups,userName);     
  43:     
  44: }
  45: </script>            

 

If you have questions, please ask them!



Oct
15
Filed Under (Error, Sites) by Andy Diericks

I’ve found a nice error today on our Sharepoint implementation.

The error appear only on one site “SiteA”.

Description of the error:

By going on the Site settings on the top of the page you have a breadcrumb, by clicking on the over right site in it (SiteA), the destination was supposed to be(http://mysite/SiteAA/SiteA/), which in fact is resolved by Sharepoint to http://mysite/SiteAA/SiteA/Pages/Home.aspx but in our case the result was a nice error 500 page.

Resolution:

No real solution because I didn’t get the real explaination on that error, the workaround was to go the site permission and to inherit the rights of the parent site and re-setup the rights after.

I don’t get the real reason on that error but a hotfix exist for that: http://support.microsoft.com/kb/936867