on 05-14-2014 2:00 PM
I have a variable for a date that is 60 days old called date60days. I want to filter out any frequently used items from the launchpad gateway service where the last used date is greater than 60 days. I am unsure how to utilize the variable in my filter. I have tried the following:
$filter=myLastUsed gt datetime'" + date60days + "'&$orderby=myLastUsed desc",
I was able to do this in the javascript itself by using a condition on the for loop when adding the links as follows:
if (ostaticlinks[i].myLastUsed > date60days ) {
however, I'd rather filter this upfront rather than retrieving so much data from the backend. Do I just not have the syntax correct for the $filter?
I do not think you should build the oData URL on your own, rather make use of SAPUI5 APIs. I am assuming that you are using SAPUI5.
You can create a filter instance using belowAPIs and use this instance while binding or making oData call.
How to use it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roger,
It's not clear from the above if your URI actually functions properly with the filtering. Do you have an example of a working URI string?
Before commiting to any expressions that result from a coded algorithm, I would make certain that what I think my result will be would work. So simply test that with a REST client. If that does work, you need to focus on your formatting through code where date60days is supposed to result in a formatted date. If it doesn't work in a client, there could be various causes (for one, filters need specific filter case handlers in most implementations, don't assume it will "just work").
Your URI string should be escaped as well if escaping of requests is not implicit in your client framework.
Regards
Ron.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roger,
is variable date60days in this expected format 2014-05-14T15:08:40 ?
Regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See this thread on stackoverflow OData: Date "Greater Than" filter - Stack Overflow
you can try with javascript function which will return date in edm format 2014-05-14T00:00:00
and then use it.
Regards,
Chandra
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.