SharePoint REST interface with operators and functions
Introduction
In the previous article SharePoint REST interface we have observed how to get list data from REST interface. In this article we will see the list of operators and functions that can be used with REST interface
What information the article has
- various operators that can be used with REST interface
- various functions that can be used with REST interface
Skill Level – Medium
Filter operators
Following are the various filter operators that can be used with REST interface
eq Equal to
ne Not equal to
gt Greater than
ge Greater than or equal to
lt Less than
le Less than or equal to
and Logical and
or Logical or
not Logical negation
add Addition
sub Subtraction
mul Multiplication
div Division
mod Modulo
( ) Precedence grouping
Functions
Following are the various functions that can be used with REST interface
bool substringof(string s0, string s1)
Checks whether s0 is within s1
bool endswith(string s0, string s1)
Checks whether s0 ends with s1
bool startswith(string s0, string s1)
Checks whether s0 starts with s1
int length(string s)
Length of string s
int indexof(string s0, string s1)
Index of string s0 within s1
string insert(string s0, int pos, string s1)
Inserts s0 into s1 at position pos.
string remove(string s0, int pos)
Removes characters from position pos in s0
string remove(string s0, int pos, int length)
Removes length characters from position pos in s0
string replace(string s0, string f0, string s1)
Replaces f0 in s0 with s1
string substring(string s0, int pos)
Returns the substring from position pos in s0
string substring(string s0, int pos, int length)
Returns the substring from position pos in s0 with the length characters
string tolower(string s0)
Transforms s0 to lowercase
string toupper(string s0)
Transforms s0 to uppercase
string trim(string s0)
Removes leading and trailing whitespaces
string concat(strings s0, string s1)
Concatenates two strings
int day(DateTime dt)
Day of the date dt
int hour(DateTime dt)
Hour of the date dt
int minute(DateTime dt)
Minute of the date dt
int month(DateTime dt)
Month of the date dt
int second(DateTime dt)
Second of the date dt
int year(DateTime dt)
Year of the date dt
double round(double dbl)
Rounded value of dbl with double precision
decimal round(decimal dec)
Rounded value of dec with decimal precision
double floor(double dbl)
Floor value of dbl with double precision
decimal floor(decimal dec)
Floor value of dec with decimal precision
Examples of usage
/Employees?$filter=Id eq 1
Filter using the eq operator extracts exactly one element if the filtered element is unique
Employees?$filter=’Jac,Arth’ eq concat(FirstName, concat(‘,’, LastName))
Filter after concatinating the column values
Employees?$filter=year(Modified) eq 2010
Filter on the year of the Modified property
Employees?$filter=Id eq 3 and substring(Department, 0, 1) eq ‘I’
Filter on the result set along with expression
Conclusion
REST interface is a great way of accessing SharePoint data and hope the above operators and functions will give grater ability
to take advantage of REST interface.
December 25, 2012
В·
Adi В·
One Comment
Tags: REST Interface В· Posted in: REST Interface, Sharepoint 2010, SharePoint 2013
One Response
I’m having hardtime to get “Created” field values as DateTime object since my requirement is to get hours minutes data as well, but Created is just returning plain Text (2013-09-23T23:56:46Z), I tried to Use DateTime functions in $select but didn’t work. Is there any way to get Created values as Date object in JS
Leave a Reply