Skip to content

Releases: andrei-markeev/camljs

Release 2.13

13 Nov 13:36
Compare
Choose a tag to compare

Changes

  • It is now possible to start with <Query> tag, e.g. new CamlBuilder.Query().ToString() (see #16)
  • Calling ToString() multiple times will no longer cause different output (see #24)
  • Fix BooleanField.NotEqualTo (thanks to @viceice)
  • Strong types for ThenBy and ThenByDesc (thanks to @viceice)
  • Smaller library size

Potentially breaking changes

  • .Membership syntax that has been deprecated for many years, was finally removed! 😄 Instead of UserField("AssignedTo").Membership.SPGroup(10), use UserField("AssignedTo").IsInSPGroup(10)
  • CamlJs no longer polyfills SP.XmlWriter and Sys.StringBuilder

Release 2.12.1

09 Nov 23:26
Compare
Choose a tag to compare

Update the xmldom library because of a security vulnerability (see #44)

Note: this dependency is used only in Node.js, if you're using camljs from client-side, you can safely skip this release.

Release 2.12.0

21 Oct 10:40
Compare
Choose a tag to compare
  • FromXml now works also in node environments (supported via xmldom dependency - not included into the client-side bundle), see #25
  • CamlJs now emits "FALSE" and "TRUE" instead of "False" and "True", turns out it does matter in onprem environments, see #26

Release 2.11.0

19 Feb 22:43
Compare
Choose a tag to compare

Changes

  • new field type ContentTypeIdField, see #22
  • improved handling of empty All or Any, see #14
  • now CamlBuilder will throw error if you try to change it after it was already serialized, see #21
  • spfx example updated to latest SPFx v1.7.1

Release 2.10.0

10 Jun 10:36
Compare
Choose a tag to compare

Added support for Aggregations and GroupLimit attribute in GroupBy clause.

Example:

var query = new CamlBuilder()
    .View([
        "ID",
        { count: "Country" },
        { avg: "FlightCost" }
    ])
    .Query()
    .GroupBy("Country", true, 100)
    .ToString()

results in the following CAML:

<View>
    <ViewFields>
        <FieldRef Name="ID" />
    </ViewFields>
    <Aggregations Value="On">
        <FieldRef Name="Country" Type="COUNT" />
        <FieldRef Name="FlightCost" Type="AVG" />
    </Aggregations>
    <Query>
        <GroupBy Collapse="TRUE" GroupLimit="100">
            <FieldRef Name="Country" />
        </GroupBy>
    </Query>
</View>

Note: Aggregations should be used with RenderListData endpoint.

Release 2.9.0

20 Apr 15:52
Compare
Choose a tag to compare

Node.js support

It is now possible to use CamlJs in modern npm-based web development.

For example, like this:

npm i camljs -S

and then:

var CamlBuilder = require('camljs');
console.log(new CamlBuilder().View().ToString());

ES6 syntax also supported:

import * as CamlBuilder from 'camljs';
console.log(new CamlBuilder().View().ToString());

SPFx

SPFx example added.

Release 2.8.2

18 Apr 20:18
Compare
Choose a tag to compare

Now it is possible to create nested joins.

For this purpose, optional 3rd parameter fromList of LeftJoin/InnerJoin can be used:

/** Join the list you're querying with another list.
    Joins are only allowed through a lookup field relation.
    @param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
    @param alias Alias for the joined list
    @param fromList (optional) List where the lookup column resides - use it only for nested joins */
InnerJoin(lookupFieldInternalName: string, alias: string, fromList?: string): IJoin;

/** Join the list you're querying with another list.
    Joins are only allowed through a lookup field relation.
    @param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
    @param alias Alias for the joined list
    @param fromList (optional) List where the lookup column resides - use it only for nested joins */
LeftJoin(lookupFieldInternalName: string, alias: string, fromList?: string): IJoin;

For example, let's say we have 3 SharePoint lists:

Orders
Title
Description
Amount
Customer (lookup to Customers -> Title)

Customers
Title
City (lookup to Cities -> Title)

Cities
Title

Then, we can extend Orders with City of the customer using the following CamlJs query:

var query = new CamlBuilder().View(["Title", "City"])
	.LeftJoin("Customer", "customersList")
	.LeftJoin("City", "citiesList", "customersList")
		.Select("Title", "City")
	.Query()
	.ToString();

Result:

<View>
    <ViewFields>
        <FieldRef Name="Title" />
        <FieldRef Name="City" />
    </ViewFields>
    <Joins>
        <Join Type="LEFT" ListAlias="customersList">
            <Eq>
                <FieldRef Name="Customer" RefType="ID" />
                <FieldRef Name="ID" List="customersList" />
            </Eq>
        </Join>
        <Join Type="LEFT" ListAlias="citiesList">
            <Eq>
                <FieldRef Name="City" RefType="ID" List="customersList" />
                <FieldRef Name="ID" List="citiesList" />
            </Eq>
        </Join>
    </Joins>
    <ProjectedFields>
        <Field ShowField="Title" Type="Lookup" Name="City" List="citiesList" />
    </ProjectedFields>
    <Query />
</View>

Release 2.8.1

04 Oct 22:34
Compare
Choose a tag to compare
Bugfix for View.Query.OrderBy scenario. Fixes #2