How to incorporate the usage of AND when querying onPremisesExtensionAttributes/extensionAttribute in the MS Graph API? - microsoft-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'

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.

OData URI filter expression for NOT IN

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'''

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.

String filtering with Ax7 oData gives error

I am trying to use the Ax7 oData endpoints to search for sales quotations by Name. Using equality works just fine, but the more advanced filter functions gives me errors.
This simple EQ query works OK:
https://myAx7Server/data/SalesQuotationHeaders?$filter=SalesQuotationName eq
'Sparrow Retail'
But this query gives me the error "The type 'System.String' for the query operator is not Queryable!"
https://myAx7Server/data/SalesQuotationHeaders?$filter=startswith(SalesQuotationName,'S')
Am I doing something wrong, or is it just that these oData endpoints do not support searching by string?
Found the answer here: https://ax.help.dynamics.com/en/wiki/dynamics-ax-7-services-technical-concepts-guide/#odata-services
This is implemented as a wildcard character Example: http://host/service/EntitySet?$filter=StringField eq '*retail*'

Compare activerecord results with sorted results

I am writing a test in rspec to make sure a function is returning a correctly sorted result set. The test looks like this:
it 'returns matching accounts' do
results = Account.search(<search conditions>)
expect(results).to eq results.order(<order clause>)
end
The result sets appear to be equivalent, but the test still fails. The following test does pass:
it 'returns matching accounts' do
results = Account.search(<search conditions>)
expect(results.map &:id).to eq results.order(<order clause>).map &:id
end
I am satisfied that this test does what I need, but is there a better way to compare two ActiveRecord relations?
Account.search probably doesn't return an array of accounts, but a ActiveRecord::Relation. When you call order on a relation it will return a different relation object and therefore not match.
On the other hand if you call an method on that relation that forces the relation to actually run the query against the database, then an array is returned. map is such a method, other might be each, first, any?, load, etc.
load seems to be a good choice to use, to force actually loading the records from the database:
it 'returns matching accounts' do
results = Account.search(<search conditions>)
expect(results.load).to eq results.order(<order clause>).load
end
Another option might be to compare the result against a array, that was sorted in Ruby instead of in the database. It depends on what you really want to test, if this is a better option:
it 'returns matching accounts' do
results = Account.search(<search conditions>).load
expect(results).to eq results.sort_by(&:attribute_to_sort_on)
end

Resources