I have tried the $filter and $search directives with no luck.
Example queries that have failed:
GET .../v1/users/me/messages?$filter=categories in 'Yellow'
GET .../messages?$filter=any(categories:categories eq 'Yellow')
GET .../messages?$search="categories:Yellow"
Documentation: https://learn.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0&tabs=http
Documentation: https://learn.microsoft.com/en-us/graph/query-parameters
Please use the below query to filter the categories which have a value 'Yellow'.
https://graph.microsoft.com/v1.0/me/messages?$filter=categories/any(c:c eq 'Yellow')
Here 'Yellow' is the category which I added as a custom category.
If you are using the builtin categories like 'Blue category' or 'Yellow category' you need to use the exact string to filter it.
Related
I have been looking up OData protocol for $filter and trying to look up the syntax for filtering response from ms-graph based on categories eq 'FlexUser'.
in the response I get:
...,
"categories": [
"FlexUser"
],
...
While trying to expand categories before using filter I get an error says that categories can't be expanded. Can anyone explain how to filter on List param?
I create the category when creating the event so that category does not exist in my outlook calendar
If I understand you right, you are fetching a list of events with e.g.
/v1.0/me/calendar/events
and want to filter all events which contain a specific category.
In this case you have to use the any operator in your filter:
$filter=categories/any(c:c eq '#break')
So your request could look like this:
/v1.0/me/calendar/events?$filter=categories/any(c:c eq 'FlexUser')
I need to get value field2 from list values in field1. Field1 is relation many2many with field in another model.
I tried to use domain for it but everytime I received error.
class filial_page_products(models.Model):
gallery_rstamp_products_ids = fields.Many2many('product.template',
'gallery_rstamp_products_rel',
'gallery_rstamp_products_ids', 'filial_page_new_rstamp_products_ids',
'Gallery products')
default_gallery_product_id = fields.Many2one('product.template','Default maket', domain="[(default_gallery_product_id, 'in', 'filial_page_gallery_rstamp_products_ids')]")
class product(models.Model):
_inherit = 'product.template'
filial_page_gallery_rstamp_products_ids = fields.Many2many('product.template',
'gallery_rstamp_products_rel',
'filial_page_recovery_rstamp_products_ids', 'gallery_rstamp_products_ids',
'Gallery list')
filial_page_default_maket_product_ids = fields.One2many('pr_filials.filial_page_products',
'default_gallery_product_id',
'Linked page products')
How can I use domain to select only those values that are specified in the gallery_rstamp_products_ids field?
of course, I can set default_gallery_product_id from all products but I don't like it.
Your domain doesn't look quite right. The left operand should be quoted and the right side should not be quoted (unless it's actually supposed to be evaluated as a string).
domain="[('default_gallery_product_id', 'in', filial_page_gallery_rstamp_products_ids)]"
Note, there's a special format required for filtering against x2many fields (one2many or many2many). You may need to use this (below), however, there have been reports of issues using this in newer versions.
domain="[('default_gallery_product_id', 'in', filial_page_gallery_rstamp_products_ids[0][2])]"
Here's some documentation on domains.
I have the following code:
Incident::where('id','<','35')->with('priority')->paginate(15);
Right now this returns the following:
ID, title, description, priority_id and the priority object.
I would like to retrieve only ID, title and the priority object, without description nor priority_id but I want them in a specific order, like this:
ID, priority and title.
But when I do the following:
Incident::where('id','<','5')->with('priority')->paginate(15, array('id', 'priority', 'title'));
I get an error saying column incidents.priority not found.
Is there any way to select only the columns I want and in the order I want them when one of them is referenced through a FK?
Thank you!
You don't need to include priority in the list:
Incident::where('id','<','5')->with('priority')->paginate(15, array('id', 'title'));
If you pass a callback to the with method you can specify the order like so:
Incident::where('id','<','35')
->with(['priority' => function ($query) {
$query->select('id', 'priority', 'title');
}])
->paginate(15);
Your query is not a join. The with('priority') is actually a 2nd separate query that is executed after the Incident query and then attached to the Incident models. If you want to reference columns and use a join you would do it like:
Incident::select('id', 'priorities.*', 'incidents.title')
->leftJoin('priorities', 'priorities.id', '=', 'incidents.priority_id')
->where('incidents.id', '>', '5')
->paginate(15);
If you don't want to use the above then #tam answer would be best but make sure with his solution to include the id in the sub query callback because that is how the relation attaches itself to the parent model after the query is ran.
I need a way to locate a Magento object my multiple attributes. I can look up an object by a single parameter using the 'loadByAttribute' method, as follows.
$mageObj->loadByAttribute('name', 'Test Category');
However, I have been unable to get this to work for multiple parameters. For example, I would like to be able to do the above query using all of the following search parameters. It might look something like the following.
$mageObj->loadByAttribute(array('entity_id' => 128,
'parent_id' => 1,
'name' => 'Test Category'));
Yes, I know that you don't need all of these fields to find a single category record. However, I am writing a module to export and import a whole website, and I need to test if an object, such as a category, already exists on the target system before I create it. To do this, i have to check to see if an object of the same type, with multiple matching attributes already exists, even if it's ID is different.
This may not answer your question, but it may solve your problem.
Magento does not support loadByAttribute for multiple attributes, but instead you can do this.
$collection = $mageObj->getCollection()
->addAttributeToFilter('entity_id', 128)
->addAttributeToFilter('parent_id', 1)
->addAttributeToFilter('name', 'Test Category');
$item = $collection->getFirstItem();
if ($item->getId()){
//the item exists
}
else {
//the item does not exist
}
addAttributeToFilter works for EAV entities (products, categories, customers).
For flat entities use addFieldToFilter.
There is a special case for sales entities (orders, invoices, creditmemos and shipments) that can use both of them.
In magento, I need to pull all categories that have text "test-category-block" in the description.
I tried to add addFieldToFilter but doesn't work.
Is there an easy way to do it?
Update:
Just found another question, this might help me: Magento categories listing using getCollection & addLevelFilter but exclude Default Root Category
SOLVED:
$_collection = Mage::getResourceModel('catalog/category_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('level',array('gt' => 1))
->addAttributeToFilter('description', array('like' => '%category-search-filter%'));
You probably want to do this to filter on text within the description field:
$categories = Mage::getModel('catalog/category')->getCollection()
->addFieldToFilter('description', array('like' => '%test-category-block%'))
If you don't use the like array param, then it will do only match on descriptions that equal the provided value, not that contain it.