Thursday, February 16, 2012

SPMetadata - SharePoint metadata query facilitation

While developing custom field types I found out that I often had to make queries to different metadata of different sites via different identifiers. For example, a list can be identified via both site-relative URL and ID. And if you want to get it according to Best Practices: Using Disposable Windows SharePoint Services Objects, you will have to determine SPSite and SPWeb identifiers which can be different.

It was necessary to get rid of these annoying dilemmas in order to be able to focus on developing of custom field types.


Sunday, February 5, 2012

SharePoint Extended lookup field. Part 2: Value display in ListViewWebPart using jQuery+JSON

In the first article of the blog I wrote about displaying field values in (Render Pattern) Display Pattern using web-services and JavaScript. This method is good enough… However, if we have large volume of data to display the productivity will be low. The reason is that every time field value isn’t filled a web-service is called and a wsdl answer is parsed. Probably this method of displaying values by this type of field can satisfy an end-user it’s unlikely that metadata field will be widely used). However, it won’t work with Extended Lookup Field.

The first idea for automation is a onetime call of a web-service to transfer an array of nonrecurring field values. And it’s better to choose another data format instead of XML. Using jQuery is one of the best ways to select necessary items on a HTML page. Choosing this framework it’s better to send and receive data in JSON format. Moreover there are all necessary metadata for it in NET Framework 3.5 SP1.

As far as web-service call will be made only once it’s better to make this via element event in HeaderPattern.  Such element will be iframe element with onload event. A part of the HeaderPattern code for this decision is given below.
<RenderPattern Name="HeaderPattern">
  <HTML><![CDATA[<script src="/_layouts/jQuery/jquery-1.6.4.js"></script>]]></HTML>
  <HTML><![CDATA[<script src="/_layouts/jQuery/json2.js"></script>]]></HTML>
  <HTML><![CDATA[<script src="/_layouts/ExtLookup.js"></script>]]></HTML>
  <HTML><![CDATA[<iframe id="Header]]></HTML>
  <List/>
  <Property Select="Name"/>
  <HTML><![CDATA[" height="0" width="0" onl oad="GetExtValueAJAX(&quot;div_]]></HTML>
  <List/>
  <Property Select="Name"/>
  <HTML><![CDATA[&quot;, &quot;]]></HTML>
  <HttpVDir/>
  <HTML>
    <![CDATA[&quot;, &quot;]]>
  </HTML>
  <List/>
  <HTML>
    <![CDATA[&quot;, &quot;]]>
  </HTML>
  <Property Select="Name"/>
  <HTML>
    <![CDATA[&quot;);"></iframe>]]>
  </HTML>
</RenderPattern>

Sunday, January 22, 2012

SharePoint Extended lookup field. Part 1: Using EntityEditorWithPicker.


I’m sure that many users were faced with the necessity to enter in lookup field items from two or more lists. And I’ve got an idea to make this opportunity for SharePoint users. To my surprise I found out that it can be assembled of already existing solutions.

Custom PickerDialog and SimpleQueryControl

The developing started from reading the article Customizing EntityEditorWithPicker. If we take the example given in the article as a basis it will be easy to make our own user EntityEditorWithPicker. It results in extension of three classes: EntityEditorWithPicker, PickerDialog and SimpleQueryControl. The extension of the first class is simple. However the situation with the second and the third classes is much more interesting. As it was said before the user should be given an opportunity to select items from several lists. Looking ahead, I must specify that this control will firstly provide the opportunity to select one or another list (i.e. it will be a set of controls). 

SharePoint Extended lookup field

Thursday, December 22, 2011

SharePoint Metadata field. Part 2: Custom Filter.aspx page

Part 1 - Web Services in DisplayPattern.

Displaying of field values in RenderPattern named HeaderPattern (displaying filtered values in a field header, to be more exact) is the second important point which is worth attention by SharePoint custom field types development.

In this field type pattern CAML markup is practically the same as HeaderPattern in Lookup field type with the exception of the first string which is given in Part 1. The changes will affect the   /_layouts/Filter.aspx page which is called by clicking on the field header.

If we have a look at the result of a query made after customization which is given in Part 1 we will be disappointed:

Custom Filter.aspx page



Wednesday, December 21, 2011

SharePoint Metadata field. Part 1: Web Services in DisplayPattern


Once I was faced with the necessity of storing data of lists in… lists.

The first idea was to use standard set of SharePoint data types but I had to refuse it because it wasn’t a proper decision for solving such problems.