SOLVED

Complex Queries with Microsoft graph on SharePoint

%3CLINGO-SUB%20id%3D%22lingo-sub-2798284%22%20slang%3D%22en-US%22%3EComplex%20Queries%20with%20Microsoft%20graph%20on%20SharePoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2798284%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20been%20trying%20to%20replicate%20my%20PowerApps%20function%20filter%20on%20Microsoft%20graph.%20Using%20the%20Graph%20API%20for%20SharePoint%20documentation.%20However%2C%20I%20am%20unable%20to%20group%20the%20various%20queries%20as%20seen%20below.%20I%20have%20not%20found%20any%20MS%20article%20on%20multiple%20queries.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPowerApps%20Query%20%3D%26gt%3B%20%20%20%20%20%20MeetingRoom%3DselectedRoom%20%26amp%3B%26amp%3B%20((ArrivalDateAndTime%26lt%3B%3DselectedStart%20%26amp%3B%26amp%3B%20ArrivalEndDateAndTime%26gt%3BselectedStart)%20%7C%7C%20((ArrivalDateAndTime%3CSELECTEDEND%3EselectedEnd)%20%7C%7C%20(ArrivalEndDateAndTime%26gt%3BselectedStart%20%26amp%3B%26amp%3B%20ArrivalEndDateAndTime%26lt%3B%3DselectedEnd))%3C%2FSELECTEDEND%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20been%20able%20to%20do%20this%20that's%20the%20first%20part%20of%20the%20query%20and%20it%20works%20(%20as%20seen%20below).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EMeetingRoom%20eq%20'General%20Board%20Room'%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHowever%2C%20I%20have%20the%20rest%20of%20the%20query%20to%20complete%20and%20MS%20graph%20does%20not%20accept%20brackets%20'%3CSTRONG%3E(%3C%2FSTRONG%3E'%20'%3CSTRONG%3E)%3C%2FSTRONG%3E'%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22inherit%22%3EI%20have%20written%20what%20I%20%3C%2FFONT%3Ebelieve%3CFONT%20face%3D%22inherit%22%3E%26nbsp%3Bthe%20query%20should%20be%20like%2C%20with%20the%20brackets.%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20(%3C%2FP%3E%3CP%3E(fields%2FArrivalDateAndTime%26lt%3B%3D2021-07-30T06%3A41%3A30Z%20and%20fields%2FArrivalEndDateAndTime%26gt%3B2021-07-30T06%3A41%3A30Z)%3C%2FP%3E%3CP%3Eor%3C%2FP%3E%3CP%3E(fields%2FArrivalDateAndTime%26lt%3B2021-09-30T06%3A41%3A30Z%20and%20fields%2FArrivalEndDateAndTime%26gt%3B2021-09-30T06%3A41%3A30Z)%3C%2FP%3E%3CP%3Eor%3C%2FP%3E%3CP%3E(fields%2FArrivalEndDateAndTime%26gt%3B2021-07-30T06%3A41%3A30Z%20and%20fields%2FArrivalEndDateAndTime%26lt%3B%3D2021-09-30T06%3A41%3A30Z)%3C%2FP%3E%3CP%3E)%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EGraph%20Query%201%3D%26gt%3B%20%20https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fsites%2F6e81a6f9-4953-4a8d-8ebf-a0764aa4aefe%2Flists%2F397b7365-5ff3-48d4-8b72-af2ad17165e9%2Fitems%3F%24expand%3Dfields%26amp%3B%24filter%3Dfields%2FMeetingRoom%20eq%20'General%20Board%20Room'%20and%20fields%2FMeetingRoom%20eq%20'Bar'%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20how%20do%20I%20group%20these%20queries%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2798284%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20Graph%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

I have been trying to replicate my PowerApps function filter on Microsoft graph. Using the Graph API for SharePoint documentation. However, I am unable to group the various queries as seen below. I have not found any MS article on multiple queries. 

 

 

PowerApps Query =>      MeetingRoom=selectedRoom && ((ArrivalDateAndTime<=selectedStart && ArrivalEndDateAndTime>selectedStart) || ((ArrivalDateAndTime<selectedEnd && ArrivalEndDateAndTime>selectedEnd) || (ArrivalEndDateAndTime>selectedStart && ArrivalEndDateAndTime<=selectedEnd))

 

 

I have been able to do this that's the first part of the query and it works ( as seen below).

 

MeetingRoom eq 'General Board Room'

 

However, I have the rest of the query to complete and MS graph does not accept brackets '(' ')'

I have written what I believe the query should be like, with the brackets. 

 

and (

(fields/ArrivalDateAndTime<=2021-07-30T06:41:30Z and fields/ArrivalEndDateAndTime>2021-07-30T06:41:30Z)

or

(fields/ArrivalDateAndTime<2021-09-30T06:41:30Z and fields/ArrivalEndDateAndTime>2021-09-30T06:41:30Z)

or

(fields/ArrivalEndDateAndTime>2021-07-30T06:41:30Z and fields/ArrivalEndDateAndTime<=2021-09-30T06:41:30Z)

)

 

 

 

Graph Query 1=>  https://graph.microsoft.com/v1.0/sites/6e81a6f9-4953-4a8d-8ebf-a0764aa4aefe/lists/397b7365-5ff3-48d4-8b72-af2ad17165e9/items?$expand=fields&$filter=fields/MeetingRoom eq 'General Board Room' and fields/MeetingRoom eq 'Bar'

 

 

Please how do I group these queries?

1 Reply
best response confirmed by Chuksobi (New Contributor)
Solution
I have gotten around this as the endpoint accepts brackets '(' ')' for multiple grouping. My query had an invalid character.