I’ve tried a million different things based on tons of different forums and documentation, and I just can’t figure this out. We have a Sharepoint view with this filter:
How do I convert this to an odata query for the For Each List Item activity?
I’ve tried a million different things based on tons of different forums and documentation, and I just can’t figure this out. We have a Sharepoint view with this filter:
How do I convert this to an odata query for the For Each List Item activity?
That is not what I’m asking. I can’t just replace the date with an expression. I need to do it in the odata filter itself. Something like…
fields/Created lt Today()
Thats exactly what I have shared.
You need to paste this into filter under for each list item
String.Format("fields/Created lt ‘{0}’ ", Datetime.Now.ToShortDateString())
OR
String.Format("fields/Created lt ‘{0}’ ", Today())
That is not what you shared. You shared an expression that has Datetime.Now.ToShortDateString()) hard-coded into it.
I need the ODATA FILTER ITSELF to do this, not to replace a date from an expression into the filter string.
Again, the filter ITSELF needs to be something like:
fields/created lt Today
Imagine it this way…you’re storing the odata filter in a config file so you can’t put String.Format etc into the config file, so the odata filter itself has to contain the logic for “before today.”
I can’t use an expression. That’s it. I can’t use an expression. I need the “before today” to be IN THE ODATA QUERY, not replaced into it with String.Format.
I can’t hard-code the date. Again, I need the “before today” logic IN THE ODATA QUERY, no hard-coded dates, no replacing, no string.format. The “before today” has to be IN THE ODATA QUERY FILTER.
looks like date needs to be in specific format for use in Odata.
refer above post, might help you
No. I can’t hard-code the date in the odata filter. It has to be dynamic, the “before today” logic needs to be IN THE FILTER. You just don’t understand what I’m asking, so please let’s see if anyone else knows how to do this.
I think when you need to provide a variable in the odata query, it needs to be in a string.Format() like the way i described..
String.Format("fields/Created lt ‘{0}’ ", your variable name goes here)
Also, looks like you date variable has to be in a certain format for it to work, refer above post for same.
Hope this helps
I’m not explaining it again. I can’t do it that way. Please stop.
I understand you want to use from config..you cannot put string.format but you can put what is there inside it in config
And {0},{1} etc can be used to replace calues you need
If you want to control today yesterday ..10 days before you can do that also by adding alogiv like adddays and pass days from config
Odata filter by default is just a filter but not something which would calculate expressions..what you see on sharepoint list also id you are selecting today but if in url it would canculate date and add it..that is how it would work
Cheers
I can’t do it that way. I cannot use String.Format, .Replace, or anything like it in my code. The FILTER ITSELF must do the “before today” logic.
Odata filter by default is just a filter but not something which would calculate expressions
That’s not correct. There are functions and other things you can use in an odata filter, I just can’t figure out the correct syntax.
Unfortunately odata does not support it
Functions like substring etc are there but not related to date..the assumption you have itself is wrong. But all the best in the search..
Cheers
A lot of us are having a difficult time understanding why you can’t manipulate the URL before sending it. The solutions provided assume you have the ability to manipulate the URL.
You could try this:
your_odata_endpoint?$filter=Created lt Date(now())
Because the filter is being provided in an argument, not hard-coded.