Release 2.0

Rating:        Based on 2 ratings
Reviewed:  2 reviews
Downloads: 580
Change Set: 6926b2bb69a0
Released: Aug 26, 2013
Updated: Aug 26, 2013 by omlin
Dev status: Beta Help Icon

Recommended Download

Application camljs.js
application, 36K, uploaded Aug 25, 2013 - 552 downloads

Other Available Downloads

Application camljs.d.ts
application, 21K, uploaded Aug 25, 2013 - 28 downloads

Release Notes

Bracket expressions and partial query generation

This is the main improvement comparing to the version 1.0, where you couldn't create complex queries because of lack of bracket expressions support.

Two new methods were added to the builder chain in order to support that: Any & All.

/** Adds And clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
All(...conditions: IExpression[]): IExpression;

/** Adds Or clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
Any(...conditions: IExpression[]): IExpression;

You can use these methods in conjunction with CamlBuilder.Expression() for creating bracket expressions, for example like this:
var camlQuery = new CamlBuilder().Where().Any(
    CamlBuilder.Expression().TextField("Email").EqualTo("support@google.com"), 
    CamlBuilder.Expression().TextField("Email").EqualTo("plus@google.com"), 
    CamlBuilder.Expression().TextField("Title").BeginsWith("[Google]"), 
    CamlBuilder.Expression().TextField("Content").Contains("Google")
).ToString();


As a side effect, you can now create parts of your query separately via CamlBuilder.Expression(), and then merge them together at some point later. Also you can use CamlBuilder.Expression() for defining CAMLQuery attribute in SPServices.

Better Intellisense

Intellisense significantly improved: now different types of fields have different sets of comparison options. Field usage is made more obvious.
  1. LookupField element improved. No more misleading "casting" of lookups to the target field types: now lookup fields expose methods Id() and ValueAs<type of field>().
  2. BooleanField element added for fields of boolean type.
  3. UrlField element added for fields of type URL.
  4. DateRangesOverlap element improved. It turns out, you cannot use this element in CSOM, because CSOM ignores QueryOptions element. But you still can use DateRangesOverlap with SPServices.
  5. UserField element improved.

Migration from version 1.0 to version 2.0

None of old elements were removed, but syntax is now more strict, thus in some cases it is possible that some migration will be necessary. Please, post your problems to discussions, if you will have any.

Also, please keep in mind that some elements were marked as deprecated:
  1. LookupIdField element marked as deprecated and will be removed in the next major release. Please, use LookupField(...).Id() instead.
  2. Membership element marked as deprecated and will be removed in the next major release. Functionality of Membership element was replaced with set of methods under UserField element.

TypeScript implementation

CamlBuilder is now implemented in TypeScript and thus can be used seamlessly by Typescript developers. Of course, you can still use JavaScript version for pure JS development.

Internally, TypeScript unit tests (tsUnit) are now used, helping to make the library much more stable. New tests are added.

Nuget

CamlBuilder is now available via Nuget.

JavaScript:

PM> Install-Package CamlJs


TypeScript definitions:

PM> Install-Package camljs.TypeScript.DefinitelyTyped

Reviews for this release

     
This is an essential for SharePoint JavaScript development projects. It's one of the first libraries I include in any new SharePoint 2010 Team Sites.
by ijmercedes on Dec 6, 2013 at 1:23 AM
     
It is an excellent tool for anybody who develops Sharepoint client side solutions.
by BigZolo on Dec 4, 2013 at 3:00 PM