OData URI filter expression for NOT IN - odata

I have a PowerShell script that has the following ODATA URI $filter expression.
...?$filter=(Web eq ''N'' or Web eq ''W'') and Item_Type ne ''I'''
How can I add a "NOT IN" statement similar to SQL which would be something like
Brand NOT IN {'A' 'B' 'C' 'D'}
EDIT: This is for Microsoft Business Central FWIW.

Something like this should work
not(property in ('v1', 'v2'))
For your property Web
...?$filter=not(Web in (''N'',''W'')) and Item_Type ne ''I'''
If not filter option is not supported you can use ne and and operators
property ne 'V1' and property ne 'V2'
Query:
...?$filter=Web ne ''N'' and Web ne ''W'' and Item_Type ne ''I'''

Related

Expanded SingleValueExtendedProperties do not show up when combined with $select

I'm currently using Microsoft Graph to retrieve appointments from a users calendar. I need to access the singleValueExtendedProperties and only a few properties of the appointment.
Accessing this url
https://graph.microsoft.com/v1.0/users/XXXXXX/calendarView?startDateTime=2023-05-01T12:00:00&endDateTime=2023-05-30T12:00:00&$expand=singleValueExtendedProperties($filter=id eq 'String {GUID1} Name Creator' or id eq 'String {GUID2} Name Type')&$top=50
returns the entire appointments with it's singleValueExtendeProperties.
However, when I combine that with a select like so
https://graph.microsoft.com/v1.0/users/XXXXXX/calendarView?startDateTime=2023-05-01T12:00:00&endDateTime=2023-05-30T12:00:00&$expand=singleValueExtendedProperties($filter=id eq 'String {GUID1} Name Creator' or id eq 'String {GUID2} Name Type')&$select=id,start,end,isAllDay,showAs,categories,subject,sensitivity,singleValueExtendedProperties&$top=50
I only get the selected fields without the singleValueExtendedProperties.
Am I doing something wrong?
This is a known issue/bug with the Graph Microsoft Graph -> Use the singleValueExtendedProperty in OData $select when expanded $expand one way of working around it is to include the extendedproperty you want returned in a filter clause, even though you may not want to filter items you can make your filter generic so it just returns all item with that property eg this is an example just using the extended property for subject (note your shouldn't have
https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2022-09-01T19:00:00Z&endDateTime=2022-09-10T19:00:00Z&$select=Subject,Start,End,singleValueExtendedProperties&$expand=singleValueExtendedProperties($filter=id eq 'String 0x0037')&$filter=singleValueExtendedProperties/any(ep: ep/id eq 'String 0x0037' and ep/value ne null)
IMO Microsoft should just fix this on the backend.

How to incorporate the usage of AND when querying onPremisesExtensionAttributes/extensionAttribute in the MS Graph API?

I'm currently trying to query multiple values when it comes to onPremisesExtensionAttributes/extensionAttribute in MS Graph API.
I'm able to query this one:
https://graph.microsoft.com/beta/users?$count=true&$filter=onPremisesExtensionAttributes/extensionAttribute1 eq 'attr1'
But I want to query more values than attr1, but I haven't managed to get it to work.
I've tried queries, such as these two:
https://graph.microsoft.com/beta/users?$count=true&$filter=onPremisesExtensionAttributes/extensionAttribute1 eq 'attr1' and 'attr2' and 'attr3'
https://graph.microsoft.com/beta/users?$count=true&$filter=onPremisesExtensionAttributes/extensionAttribute13 eq 'attr1'&$onPremisesExtensionAttributes/extensionAttribute1 eq 'attr2'&$onPremisesExtensionAttributes/extensionAttribute1 eq 'attr3'
the correct syntax should be
$filter=onPremisesExtensionAttributes/extensionAttribute13 eq 'attr1' and onPremisesExtensionAttributes/extensionAttribute13 eq 'attr2' and onPremisesExtensionAttributes/extensionAttribute13 eq 'attr3'
one filter param to include all conditions, and each condition is full - field eq 'value'

How to get EndRecurrenceDate using microsoft graph api

I am trying to get EndRecurrenceDate using ms graph api by referring this documents .link 1
none of followings didn't work for me . what could be the reasons
https://graph.microsoft.com/v1.0/me/events/{event-id}==?$expand=singleValueExtendedProperties($filter=id eq 'String {6ED8DA90-450B-101B-98DA-00AA003F1305} Id 0x0000000F')
.
I chnaged expand query but it also does not give any value for singleValueExtendedProperties in API response
$expand=singleValueExtendedProperties($filter=id eq 'Date {6ED8DA90-450B-101B-98DA-00AA003F1305} Id 0x0000000F')
$expand=singleValueExtendedProperties($filter=id eq 'String {6ED8DA90-450B-101B-98DA-00AA003F1305} Id 0x0000000F')
$expand=singleValueExtendedProperties($filter=id eq 'String {6ED8DA90-450B-101B-98DA-00AA003F1305} Name PidLidEndRecurrenceTime')
In MS-Graph API, please retrieve the seriesMaster by passing the seriesMasterId corresponding to the given event:
https://learn.microsoft.com/en-us/graph/api/resources/event?view=graph-rest-1.0
For verification, please check the field "type" which specifies the event type. It should have value "seriesMaster".
In the seriesMaster that has been retrieved, the field "end" will represent the end date of the recurrence.

Does OData query support nested filters with AND/OR operators?

Does OData query support nested filters with AND/OR operators?
By nested query, I mean query similar to this:
((FieldA < 50 OR FieldA > 100) AND FieldB == "MyString")
I am building an OData query editor control, so I need to know if these are available.
Thanks!
Yes it does. E.g.:
GET http://services.odata.org/v4/TripPinServiceRW/People?$filter=(FirstName ne 'Mary' and LastName ne 'White') and UserName ne 'marywhite'
You can try it yourself in a browser.

OData not operator, or how to filter for all items which not startswith(...)

I am using the SharePoint REST API, which is similar to OData, but currently I don't even know the standard OData way. I would like to filter items that do not start with a certain string pattern. How is the 'not' operator written in OData? All references list 'and' and 'or' operators and 'ne' operators, but I cannot find one for 'not'.
Neither of the following work:
a)
not startswith(field, 'pattern')
b)
startswith(field, 'pattern') ne true // Yes I know there is no 'true' boolean literal.
Even though the diagram from Use OData query operations in SharePoint REST requests illustrates that the proper syntax for startswith operator is:
filter=startswith(PropertyName, 'String') Eq Boolean
it seems the only syntax it accepts is:
filter=startswith(PropertyName, 'String')
For example, the request:
/_vti_bin/listdata.svc/Pages?$filter=startswith(Title,'SharePoint') eq false
returns pages those Title does not start with SharePoint
But the same request using _api service endpoint
/_api/Web/Lists/getByTitle('Pages')/items?$filter=startswith(Title,'SharePoint') eq false
returns The query is not valid exception.
Solution
Utilize listdata.svc endpoint since it fully supports the syntax of startswith operator as specified in OData specification.

Resources