MSFlow filter SharePoint list in GetItems action by date field

%3CLINGO-SUB%20id%3D%22lingo-sub-65659%22%20slang%3D%22en-US%22%3EMSFlow%20filter%20SharePoint%20list%20in%20GetItems%20action%20by%20date%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-65659%22%20slang%3D%22en-US%22%3E%3CP%3EI%20was%20attempting%20to%20create%20a%20flow%20that%20executed%20a%20GetItems%20action%20that%20would%20use%20the%20ODATA%20filter%20field%20to%20limit%20the%20rows%20to%20those%20where%20a%20date%20field%20(ProjectEnd)%20was%20less%20than%20or%20equal%20to%20the%20current%20date%2Ftime.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20accomplished%20this%20by%20creating%20a%20composed%20string%20variable%20that%20was%20the%20filter%20portion%20of%20what%20will%20be%20essentially%20a%20REST%20call%20to%20SharePoint.%20%26nbsp%3BSo%20if%20you're%20familiar%20with%20SharePoint%20REST%20call%20formats%20your%20goal%20will%20be%20to%20attain%20the%20same%20result%20and%20the%20query%20should%20work.%20%26nbsp%3BIn%20this%20case%20I%20needed%20the%20REST%20call%20to%20have%20%24filter%3DProjectEnd%20lt%20'%3CSPAN%3E2017-04-27T19%3A51%3A38.7610450Z'.%20%26nbsp%3BThat%20turned%20out%20to%20be%20tricky%2C%20but%20knowing%20that%20the%20browser%20would%20encode%20the%20single%20quotes%20anyway%20I%20just%20jumped%20ahead%20and%20did%20it%20in%20my%20variable.%20%26nbsp%3BThe%20resulting%20variable%20looks%20like%20this%3A%26nbsp%3BProjectEnd%20lt%20%25272017-04-27T19%3A51%3A38.7610450Z%2527%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20493px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F13893i8561D180DC90002E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22FlowODATA.png%22%20title%3D%22FlowODATA.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20result%20of%20this%20Compose%20can%20then%20be%20attached%20to%20the%20filter%20of%20the%20GetItems.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EKEY%3A%20when%20you%20actually%20create%20this%20compose%20action%20item%2C%20put%20(double%20quotes)%20%22%20around%20the%20value%2C%20they%20do%20not%20show%20once%20you've%20saved%20the%20flow%20but%20are%20critical%20to%20make%20it%20work.%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-65659%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-93998%22%20slang%3D%22en-US%22%3ERe%3A%20MSFlow%20filter%20SharePoint%20list%20in%20GetItems%20action%20by%20date%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-93998%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20helped%20me%20with%20my%20flow.%20Thanks%20for%20your%20post.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
MVP

I was attempting to create a flow that executed a GetItems action that would use the ODATA filter field to limit the rows to those where a date field (ProjectEnd) was less than or equal to the current date/time.

 

I accomplished this by creating a composed string variable that was the filter portion of what will be essentially a REST call to SharePoint.  So if you're familiar with SharePoint REST call formats your goal will be to attain the same result and the query should work.  In this case I needed the REST call to have $filter=ProjectEnd lt '2017-04-27T19:51:38.7610450Z'.  That turned out to be tricky, but knowing that the browser would encode the single quotes anyway I just jumped ahead and did it in my variable.  The resulting variable looks like this: ProjectEnd lt %272017-04-27T19:51:38.7610450Z%27

 

FlowODATA.png

 

The result of this Compose can then be attached to the filter of the GetItems.

 

KEY: when you actually create this compose action item, put (double quotes) " around the value, they do not show once you've saved the flow but are critical to make it work.

1 Reply
Highlighted

This helped me with my flow. Thanks for your post.