OData : Operands of logical operator 'AND' are not valid - filter

I am trying to call an OData report with the following URL :
https://myXXXXX.sapbydesign.com/sap/byd/odata/crm_customerinvoicing_analytics.svc/RPCRMCIVIB_Q0001QueryResults?&$filter=PARA_CAL_DAY%20gt%20datetime%272017-01-01T00:00:00.000%27%20and%20PARA_CAL_DAY%20lt%20datetime%272017-01-02T00:00:00.000%27&$skip=0
As you can see I am trying to use the and operator inside a filter property but I received the error in the title of this post.
I tried :
$filter=(MyFilter1) and (MyFilter2)
$filter=(MyFilter1 and MyFilter2)
$filter=(MyFilter1 AND MyFilter2)
But I still have an error. Any ideas ?

Just in case someone stumbles upon this thread first, this is error occurs when the same field is used to filter the dataset twice (greater than+less than, greater than+less than or equal to, etc)
SAP issue report

Related

error parsing dynamic link query using Microsoft Json Rules engine

Using Microsoft Json Rules engine.
The following rule expressions parse without an issue:
"Names[0].PersonName.FirstName=="Paul""
Names.Any()
but 3. throws the following parse exception
"Names.Any(n=>n.PersonName.FirstName=="Paul")"
Exception while parsing expression Names.Any( n => n.PersonName.FirstName=="Paul") - Unable to cast object of type 'System.Linq.Expressions.InstanceMethodCallExpression1' to type 'System.Linq.Expressions.ParameterExpression'.
Dr. Google is not very helpful on this one.
Any feedback, directions, pointers etc. greatly appreciated.
I was expecting the expression to parse and when evaluated return, true, given 1. above is true.
Dynamic Linq using a operator called "it" to refer to the current instance.a
Changing the expression to the following:
"Names.Any(it.PersonName.FirstName=="Paul")" solved the problem for me.

Power Automate: Create_Item Failed

I am trying to create an intake process where where a response from a Microsoft Form creates an item into our SharePoint queue for my team to work. This workflow has some branching so some questions may not always need answers. When the "Date of Change" field is used as intended in the workflow by the user, everything works correctly and appears in our queue. When the user goes down a path where the "Date of Change" field is not needed or a part of the workflow, I receive the below error and the results are never pushed to our queue.
Error Message:
The 'inputs.parameters' of workflow operation 'Create_item' of type 'OpenApiConnection' is not valid. Error details: Input parameter 'item/DateofChange' is required to be of type 'String/date'. The runtime value '""' to be converted doesn't have the expected format 'String/date'.
Workflow Images:
To fix this I have tried making the field "Not required" in hopes that if left blank it would not get read by the flow.
I have also tried, changing the format of the column from Date and time to Single Line of Text and neither of those have worked.
Try an expression instead of the dynamic content field. In this expression check for empty with the empty function. If it is empty use the null value.
Below is an example
Make sure you change the question id to your question id in the expression.
if(empty(outputs('Get_response_details')?['body/rec7e8e58aab84f49a27cacc460a7eeaf']), null, outputs('Get_response_details')?['body/rec7e8e58aab84f49a27cacc460a7eeaf'])

Google Cloud, compute.instances.aggregatedList with filter fails

The google cloud API for compute.instances.aggregatedList includes filter argument.
https://cloud.google.com/compute/docs/reference/rest/beta/instances/aggregatedList
I use (status eq "RUNNING") as a filter to view all my running instances.
I would like to have a more elaborate criteria, such as one that uses labels and or other terms, however even the Google documentation terms (that use OR operator) returns an error, For example - even Google documentation example:
(cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell")
fails with error 400:
"message": "Invalid value for field 'filter': ' (cpuPlatform = \"Intel
Skylake\") OR (cpuPlatform = \"Intel Broadwell\")'. Invalid list
filter expression."
it looks as if the '=' signs are not accepted, and AND/OR operators are not accepted.
What is the correct format for this API.
I had the same issue when I used "=" instead of "eq" in google-api-python-client. I required to use labels to filter the aggregated instances list. At first I used
filter="labels.projectid=test-project"
which returned 400 error in aggregated list but was successful if it was queried for instances of specific zone.
I achieved the list successfully when I used filter as
filter="labels.projectid eq \"test-project\""
or
filter = "labels.projectid eq test-project"
I even tested it using REST-Client provided by google and it worked.
Reference: https://issuetracker.google.com/80238913
Even 3 years later Google haven't fixed the bug: OR and AND operators are not supported even it is advertised:
https://cloud.google.com/compute/docs/reference/rest/v1/instances/aggregatedList
Google API is famous for inconsistency and false promises. Just relax and do 2 queries to emulate OR.
For AND operator just omit AND and quote comparison expressions into parentheses:
(name eq 'stage-.*') (labels.env ne "SKIP")
Note I use eq / ne with regex instead of operators =, !=, :.
I ran into a similar error message calling a GCP API. I finally got it to work by making the filter look like this:
fmt.Sprintf("selfLink = \"%s\"", networkLink)
Compute instances list api filter param should work with
(labels.<label_name_1>=<label_value_1>) OR (labels.<label_name_2>=<label_value_2>)
I have found that this string works as a filter within Python:
test_filter = '((labels.test="test-value") AND (labels.test-second="test-second-value")) OR ((labels.test="test-other-value"))'
This filter worked for me:
name eq my-service-v.*
Will return groups like my-service-v112 etc' (even though the name field is nested inside).

Testing jsonpath that array contains specfic objects in any order

I'm testing a Spring controller which can give back a 400 with field errors. These field errors is an array of objects containing a "path" and "message" field.
Now I want to test that some specific call returns multiple errors with specific path and message.
I cannot come to anything closer then below:
.andExpect(jsonPath("$.fieldErrors[*].path", containsInAnyOrder("title", "description")))
.andExpect(jsonPath("$.fieldErrors[*].message", containsInAnyOrder(
"The maximum length of the description is 500 characters.",
"The maximum length of the title is 100 characters.")));
But this keeps the option open that bad combinations of "path" and "message" is accepted.
Any ideas how to improve the jsonpath to test this?
This seems to the better approach:
.andExpect(jsonPath('$.fieldErrors[?(#.path == \'title\' && #.message == \'The maximum length of the title is 100 characters.\')]').exists())
Just expanding on the answer provided by Marcel, as it helped me solve the same issue but I had to modify slightly. I found that the '&&' operator wasn't supported in the version of jsonpath we currently use in one project (0.8.1), according to this issue it was marked as 'done' on Dec 8th which implies it should be available in the latest version, 2.0:
JSON Path issue 27 - AND operators
The 'old' syntax for logical AND which I ended up using is also shown on that issue and using the example above would be:
.andExpect(jsonPath('$.fieldErrors[?(#.path == \'title\')][?(#.message == \'The maximum length of the title is 100 characters.\')]').exists())
You can use org.hamcrest.Matchers.containsInAnyOrder().
.andExpect(jsonPath("$.fieldErrors[*].path", Matchers.contains("str1", "str2")))

Conditional formatting with repository variable

I am trying to conditionally format a graph with a repository variable. My goal is to end with a number between 1-12 which corresponds to the current month.
When I try,
biServer.variables['CURRENT_MONTH']
I get the following error:
Graphing engine is not responding.
"A fatal error occurred while processing the request. The server responded with: oracle.bi.nanserver.fwk.exception.BISvsException: java.lang.NumberFormatException: For input string: "2014 / 07"."
Trying the following,
RIGHT(biSerber.variables['CURRENT_MONTH'],2)
I get an error:
"A type mismatch occurred while evaluating an expression."
Finally, the follow also errors.
RIGHT('biServer.variables['CURRENT_MONTH']',2)
"The syntax of the expression to be evaluated is invalid."
Anyone have ideas? Thanks.
I ended up with a workaround that is serviceable but not ideal.
I added a new column and created a custom formula where the month number, in this case "7", is compared to the repository value CURRENT_MONTH. If CURRENT_MONTH is greater than 7, then return ".", else return "null". (The period being the least noticeable character I could think of)
From here I added the new column to the graph and set a conditional format on that column where if the value is equal to not null (a period in this instance), apply the desired conditional format.
The following link was most helpful for me.
http://bidirect.blogspot.com/2013/10/conditional-formatting-is-it-possible.html

Resources