Microsoft graph events api expand and filter - microsoft-graph-api

I am using the Microsoft.Graph.Beta/5.14.0-preview SDK to query calendar events and I am migration from an 4.22 version of the SDK. Some of my queries uses $expand and $filter on expanded properties, but for some reason I can't figure out how to re-write these queryes in the new SDK where the query builder is moved to a configuration on the get part.
My old setup looks like this:
client
.Users[userId]
.CalendarView
.Request(queryOptions)
.Filter(filterQuery)
.Expand(expandOptions)
.Select(SelectQuery)
.GetAsync()
And the re-written looks like this:
client
.Users[userId]
.CalendarView
.GetAsync(cfg =>
{
cfg.QueryParameters.StartDateTime = from;
cfg.QueryParameters.EndDateTime = to;
cfg.QueryParameters.Filter = filterQuery;
cfg.QueryParameters.Select = SelectQuery;
})
But I can't find any option to expand anymore in the new SDK - I also tried just til filter on the nested objects and then look up the event ids, but I can't filter on nested objects without expanding them.
My query that don't work look like this:
https://graph.microsoft.com/beta/me/calendarView?startDateTime=2022-12-01T00:00:00&endDateTime=2022-12-31T00:00:00&$select=id&$filter=SingleValueExtendedProperties/any(c: c/Id eq 'String {543ec2fa-e468-4b54-be8e-787c70d4a79f} Name ParentEventId' and c/Value eq 'AAMkADJiZWQxZDVmLTViNDAtNGVjOS1hZjdkLWRlMjVlNTQwYzkzOABGAAAAAADJmx9CKBiKQoBAarsrrol5BwAZTSoj4SE7Rbx0wxVE_m1BAAAAAAENAAAZTSoj4SE7Rbx0wxVE_m1BAAADk9fzAAA=')
While the one that works, and does the expand and filter correctly looks like this:
https://graph.microsoft.com/beta/me/calendarView?startDateTime=2022-12-01T00:00:00&endDateTime=2022-12-31T00:00:00&$select=id&$filter=SingleValueExtendedProperties/any(c: c/Id eq 'String {543ec2fa-e468-4b54-be8e-787c70d4a79f} Name ParentEventId' and c/Value eq 'AAMkADJiZWQxZDVmLTViNDAtNGVjOS1hZjdkLWRlMjVlNTQwYzkzOABGAAAAAADJmx9CKBiKQoBAarsrrol5BwAZTSoj4SE7Rbx0wxVE_m1BAAAAAAENAAAZTSoj4SE7Rbx0wxVE_m1BAAADk9fzAAA=')&$expand=singleValueExtendedProperties($filter=id eq 'String {543ec2fa-e468-4b54-be8e-787c70d4a79f} Name ParentEventId')
I am not sure if this is the best way of querying SingleValueExtendedProperties but the old setup works - and i can't figure out how to migrate it in the new SDK.

Related

How to exclude multiple values in OData call?

I am creating a SAPUI5 application. This application is connected to a backend SAP system via OData. In the SAPUI5 application I use a smart chart control. Out of the box the smart chart lets the user create filters for the underlying data. This works fine - except if you try to use multiple 'not equals' for one property. Is there a way to accomplish this?
I found out that all properties within an 'and_expression' (including nested or_expressions) must have unique name.
The reason why two parameters with the same property don't get parsed into the select options:
/IWCOR/CL_ODATA_EXPR_UTILS=>GET_FILTER_SELECT_OPTIONS takes the expression you pass and parses it into a table of select options.
The select option table returned is of type /IWCOR/IF_ODATA_TYPES=>EDM_SELECT_OPTION_T which is a HASHED TABLE .. WITH UNIQUE KEY property.
From: https://archive.sap.com/discussions/thread/3170195
The problem is that you cannot combine NE terms with OR. Because both parameters after the NE should not be shown in the result set.
So at the end the it_filter_select_options is empty and only the iv_filter_string is filled.
Is there a manual way of facing this problem (evaluation of the iv_filter_string) to handle multiple NE terms?
This would be an example request:
XYZ/SmartChartSet?$filter=(Category%20ne%20%27Smartphone%27%20and%20Category%20ne%20%27Notebook%27)%20and%20Purchaser%20eq%20%27CompanyABC%27%20and%20BuyDate%20eq%20datetime%272018-10-12T02%3a00%3a00%27&$inlinecount=allpages
Normally I want this to exclude items with the category 'Notebook' and 'Smartphone' from my result set that I retrieve from the backend.
If there is a bug inside /iwcor/cl_odata_expr_utils=>get_filter_select_options which makes it unable to treat multiple NE filters of the same component, and you cannot wait for an OSS. I would suggest to wrap it inside a new static method that will make the following logic (if you will be stuck with the ABAP implementation i would try to at least partially implement it when i get time):
Get all instances of <COMPONENT> ne '<VALUE>' inside a () (using REGEX).
Replace each <COMPONENT> with <COMPONENT>_<i> so there will be ( <COMPONENT>_1 ne '<VALUE_1>' and <COMPONENT>_2 ne '<VALUE_2>' and... <COMPONENT>_<n> ne '<VALUE_n>' ).
Call /iwcor/cl_odata_expr_utils=>get_filter_select_options with the modified query.
Modify the rt_select_options result by changing COMPONENT_<i> to <COMPONENT> again.
I can't find the source but I recall that multiple "ne" isn't supported. Isn't that the same thing that happens when you do multiple negatives in SE16, some warning is displayed?
I found this extract for Business ByDesign:
Excluding two values using the OR operator (for example: $filter=CACCDOCTYPE ne ‘1000’ or CACCDOCTYPE ne ‘4000’) is not possible.
The workaround I see is to select the Categories you actively want, not the ones you don't in the UI5 app.
I can also confirm that my code snippet I've used a long time for filtering also has the same problem...
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_MGW_ABS_DATA->FILTERING
* +-------------------------------------------------------------------------------------------------+
* | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITYSET
* | [<-->] CR_ENTITYSET TYPE REF TO DATA
* | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
* | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD FILTERING.
FIELD-SYMBOLS <lt_entityset> TYPE STANDARD TABLE.
ASSIGN cr_entityset->* TO <lt_entityset>.
CHECK: cr_entityset IS BOUND,
<lt_entityset> IS ASSIGNED.
DATA(lo_filter) = io_tech_request_context->get_filter( ).
/iwbep/cl_mgw_data_util=>filtering(
exporting it_select_options = lo_filter->get_filter_select_options( )
changing ct_data = <lt_entityset> ).
ENDMETHOD.

Neo4j cypher query fails with unknown syntax error

I have the following paramObj and dbQuery
paramObj = {
email: newUser.email,
mobilenumber: newUser.telephone,
password: newUser.password,
category: newUser.category,
name: newUser.name,
confirmuid: verificationHash,
confirmexpire: expiryDate.valueOf(),
rewardPoints: 0,
emailconfirmed: 'false',
paramVehicles: makeVehicleArray,
paramVehicleProps: vehiclePropsArray
}
dbQuery = `CREATE (user:Person:Owner {email:$email})
SET user += apoc.map.clean(paramObj,
['email','paramVehicles','paramVehiclesProps'],[])
WITH user, $paramVehicles AS vehicles
UNWIND vehicles AS vehicle
MATCH(v:Vehicles {name:vehicle})
CREATE UNIQUE (user)-[r:OWNS {since: timestamp()}]->(v)
RETURN user,r,v`;
Then I tried to execute
commons.session
.run(dbQuery, paramObj)
.then(newUser => {
commons.session.close();
if (!newUser.records[0]) {........
I am getting
Error: {"code":"Neo.ClientError.Statement.SyntaxError","name":"Neo4jError"}
which doesn't direct me anywhere. Can anyone tell me what am I doing wrong here?
This is actually the first time I am using the query format .run(dbQuery, paramObj) but this format is critical to my use case. I am using Neo4j 3.4.5 community with apoc plugin installed.
Ok...so I followed #inversFalcon suggestion to test in browser and came up with following parameters and query that closely match the ones above:
:params paramObj:[{ email:"xyz123#abc.com", mobilenumber:"8711231234",password:"password1", category:"Owner",name:"Michaell",vehicles:["Toyota","BMW","Nissan"],vehicleProps: [] }]
and query
PROFILE
CREATE (user:Person:Owner {email:$email})
SET user += apoc.map.clean($paramObj, ["email","vehicles","vehicleProps"],[])
WITH user, $vehicles AS vehicles
UNWIND vehicles AS vehicle
MATCH(v:Vehicles {name:vehicle})
MERGE (user)-[r:OWNS {since: timestamp()}]->(v)
RETURN user,r,v;
Now I get
Neo.ClientError.Statement.TypeError: Can't coerce `List{Map{name -> String("Michaell"), vehicles -> List{String("Toyota"), String("BMW"), String("Nissan")},.......
I also reverted to neo4j 3.2 (re: an earlier post by Mark Needham) and got the same error.
You should try doing an EXPLAIN of the query using the browser to troubleshoot it.
A few of the things I'm seeing here:
You're referring to paramObj, but it's not a parameter (rather, it's the map of parameters you're passing in, but it itself is not a parameter you can reference in the query). If you need to reference the entire set of parameters being passed in, then you need to use nested maps, and have paramObj be a key in the map that you pass as the parameter map (and when you do use it in the query, you'll need to use $paramObj)
CREATE UNIQUE is deprecated, you should use MERGE instead, though be aware that it does behave in a different manner (see the MERGE documentation as well as our knowledge base article explaining some of the easy-to-miss details of how MERGE works).
I am not sure what caused the coercion error to disappear but it did with the same query and I got a "expected parameter error" this was fixed by using $paramObj.email, etc. so the final query looks like this:
CREATE (user:Person:Owner {email: $paramObj.email})
SET user += apoc.map.clean($queryObj, ["email","vehicles","vehicleProps"],[])
WITH user, $paramObj.vehicles AS vehicles
UNWIND vehicles AS vehicle
MATCH(v:Vehicles {name:vehicle})
MERGE (user)-[r:OWNS {since: timestamp()}]->(v)
RETURN user,r,v;
which fixed my original problem of how to remove properties from a map when using SET += map.

No results returns while using 'where' clause in zend framework 2

I am using a simple select object to list all the parent categories as follows.
$select = $this->sql->select();
$select -> where(array('cat_parent_id'=>2));
$statement = $this->sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
When I run the above code, I donot have an error message but I always have a null result. If I use the where clause without the array params then I have the good results.
$select -> where('cat_parent_id=2');
To learn more, I tried to get the sql string using the code below,
$select = $this->sql->select();
$select -> where(array('cat_parent_id'=>2));
$sqlstring = $this->sql->getSqlStringForSqlObject($select);
I have a warning.
Notice: Attempting to quote a value in Zend\Db\Adapter\Platform\Mysql without extension/driver support can introduce security vulnerabilities in a production environment. in D:\wamp\www\shops\vendor\ZF2\library\Zend\Db\Adapter\Platform\Mysql.php on line 128
I really would like to use the array method inside the where clause. Any help would be very appreciated. :)

How to use was clause with Jql

i am developing report plugin for jira where i need to get assignee for given duration.it could be diffrent than current assignee in given duration.
now i am building my query in report like below.
JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder();
query = queryBuilder.where().updatedBetween(stdate,endDate).and().assignee() in(status_val).buildQuery();
return searchProvider.searchCount(query, remoteUser);
i want to get the count for prior assigned issues for given duration.
please let me know how i can use Was clause with assignee and updatedbetween dates.
regards,
tousif shaikh.
Try reading this answer. In short, you'll need to define a new clause and use it in your query, like this:
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
WasClauseImpl wasClause = new WasClauseImpl("status", Operator.WAS, new SingleValueOperand("Resolved"), new TerminalHistoryPredicate(Operator.AFTER, new SingleValueOperand(3500000L)));
JqlClauseBuilder clauseBuilder = JqlQueryBuilder.newClauseBuilder(wasClause);
Query query = clauseBuilder.buildQuery();

umbraco - how to get all of nodes by Document Type

How can I get all nodes by specific Document Type?
For example, I want to get in code behind all of nodes with Document Type: s3Article. How can I do this?
New informations:
IEnumerable<Node> nodes = uQuery.GetNodesByType("s3Article").Where(x => x.NiceUrl.Contains("en"));
lvArticles.DataSource = nodes;
lvArticles.DataBind();
This is my code. I had to use Where(x => x.NiceUrl.Contains("en")), because I have 2 language version- without Where I receive nodes from all catalogues with doctype s3Article, but I want to get only from one language version.
Problem is here:
<a href='<%# umbraco.library.NiceUrl(Tools.NumericTools.tryParseInt( Eval("id"))) %>'><%# Eval("title")%></a>
<%# Tools.TextTools.makeIMGHTML("../.."+ Eval("img").ToString(),"180") %>
<%# umbraco.library.StripHtml(Limit(Eval("Article"), 1000))%>
<%# Eval("author")%>
System.Web.HttpException: DataBinding:
'umbraco.presentation.nodeFactory.Node' does not contain a property named 'title'.
The same problem happens with the title, img, article, author. Only ID works nice. How to resolve it?
You can use the uQuery GetNodesByType(string or int) method:
IEnumerable<Node> nodes = uQuery.GetNodesByType("s3Article");
Alternatively, you can use an extension method to get all descendant nodes and then query them by type as in the following answer:
Umbraco 4.6+ - How to get all nodes by doctype in C#?
You could use this to databind to a control within a usercontrol like so:
lvArticles.DataSource = nodes.Select(n => new {
ID: n.Id,
Title: n.GetProperty("title").Value,
Author: n.GetProperty("author").Value,
Article: n.GetProperty("article").Value,
Image: n.GetProperty("img").Value,
});
lvArticles.DataBind();
Only you would need to strip the html, convert the image id to a url, etc. within the select statement as well...
As Shannon Deminick mentions, uQuery is somewhat obsolete. ExamineManager will be the fastest execution time. https://our.umbraco.org/forum/developers/api-questions/45777-uQuery-vs-Examine-vs-IPublishedContent-for-Querying
I also found it to be the easiest and most readable approach to use ExamineManager's search builder. Very flexible, and has the added benefit of being very readable due to the Fluent Builder pattern the U Team used.
This will search ALL nodes, so if you need within a specific branch, you can use .ParentId(1234) etc.
var query = ExamineManager.Instance.CreateSearchCriteria()
.NodeTypeAlias("yourDocumentType")
.Compile();
IEnumerable<IPublishedContent> myNodes = Umbraco.TypedSearch(query);
I prefer typed nodes, but you can also just use "Search()" instead of "TypedSearch()" if you prefer dynamic nodes.
Another example including a specific property value "myPropValue" == "ABC",
var query = ExamineManager.Instance.CreateSearchCriteria()
.NodeTypeAlias("yourDocumentType")
.Or() //Other predicate .And, .Not etc.
.Field("myPropValue", "ABC")
.Compile();
Ref - https://our.umbraco.org/documentation/reference/querying/umbracohelper/

Resources