Unknown's avatar

Posts by Simon Doy

I am an avid SharePoint enthusiast who works as an Independent SharePoint Consultant based in Leeds, United Kingdom. I am one of the organisers of the Yorkshire SharePoint User Group in the United Kingdom. I have been designing and building SharePoint solutions since 2006.

>Getting all people to show in a Fixed Keyword Query


>Recently I have been playing around with the out of the box search web parts. As always its not really until you have a need do you start thinking about how you could do something.

Well one of my clients wished to get a list of all the people and display which languages they spoke. When I get around to it I will go over extending the User Profiles in more detail, to be fair there are plenty of examples on the web.

To help you understand what I am doing, create a new page and add a People Search Core Results web part. Modify the web part settings and click on Fixed Keyword Query.
This is where we can get the web part to display the results automatically.

You fill in a query such as: Bob click Apply and if any of your users have the word Bob in their profile they will show.

You also need to change the Cross-Web Part query ID to a non User Query, I use Query 2.

Anyway one of the things with a fixed keyword query is that you cannot submit a wildcard query. For example: FirstName:*

If you try this then you will get a message saying that the only search terms were wildcard or something like that.

Ok so how do we get all the people to show?
However you can do the following you can query to show using the content class property.
Therefore put in the following query: contentclass:urn:content-class:SPSPeople
Click Apply and low and behold all the users popup.

Then I had to manupulate the properties that were selected and also update the XSLT.. bobs your uncle it works.

But how did you find out the Content Class?
Well I wrote a little web part which pulled out the ContentClass property.
You could extend the Selected Columns and then manupulate the XSLT. I will update this post at a later date and talk about this.

In the meantime try it out.

>InfoPath Validation Event Handlers


>I have been developing a complex solution using InfoPath to gather user information before it is processed by a SharePoint / Windows Workflow foundation solution.

One of things that the client wanted to was make use of file attachment controls. One of the requirements that the forms were only available on infopath form services. However this causes problems as we cannot validate the file attachment control.

In order to get round this we can programme a event called OnValidate_ControlName which is fired when a field has changed.

The handler provides an argument, ‘e’ which allows you to interact with InfoPath.

The keys properties of e are the following:-

  • Operation = this is the XmlOperation type that is occuring. This can be none, insert, delete and value change.
  • Site = this represents the XPathNavigator for the control that is being checked.
  • NewValue / OldValue = available for the value change operation type. This gives the developer a means to check the new and old values.

When I write an event validation function, I split the checks by Operation type. Therefore validation can be done based on the type of event.

Operation Type

The operation types are one of the following:-

  • None – fired when the form opens.
  • Value Change – fires when a value of a field is changed.
  • Insert – fires when an insertion occurs with a repeating table.
  • Delete – fires when a deletion occurs within a repeating table.

Using this method you can reduce the complexity of the checks for example you may only check that a field requires a value when a field is changed or a repeating table is inserted (to prompt the user to fill out the field.) The none operation can be used to pre-empt the user to fill out a value for a field as soon as the form is opened.

Reporting Errors

Once a problem is found, the user can be informed by the e.ReportError() function, which asks you to provide an XPathNavigator object pointing to the node with the problem. This is normally the e.Site object. There are a couple of other parameters, called Site Independent and message. The message parameter allows you to provide a simple message. An other override of the message allows more detail to be inserted. This is displayed in a separate message box.

The site independent is used in regards to when the fault clears and whether a change has to be validated against the same control or through a group control (such as a repeating table repeating field.

Tying things up

Programming this way provides some validation that is not possible in the out of the box solutions and provides a way to provide much better methods to interact with the user.