Orchard CMS - query lists from views - orchardcms

I created a list and added some items to it. From a view ( not related to this list), I am trying to access the items of this list.
I can get the list of items by using the following query :
contentManager.Query<ContentPart>("myContentTypeName")
This gives me a list.
But, consider this scenario -
-> I create an myContentTypeName and add it to a list.
-> I create another Item but didn't add it to any list.
The above query returns ALL the items of that type. How can I filter this query and get only the items that are a part of the list?
Thanks!

If you are using >= 1.4 version of Orchard, use the projector module. Starting with 1.4 List is pretty much deprecated. If you still need to use the List, I think what you want to do is query for the List content items, not the items within it.

Related

How get List of items from Netsuite using java api

How I can get Item list from NetSuite using suite talk java API. I am
able to get single item using internal Id but I need to get All list of items or by pagination (batch). Please advise how can I do this?
Code for get one inventory item:
RecordRef recordRefs=new RecordRef();
recordRefs.setType(RecordType.inventoryItem);
recordRefs.setInternalId("6")
ReadResponseList responseList = client.callGetRecords(recordRefs);
Use a search. You'll probably want an advanced search, since you're retrieving so many results. Here's a great example of an advanced search with pagination: https://stackoverflow.com/a/47538464/10393810
(Note that you will be using an ItemSearchAdvanced, not TransactionSearchAdvanced as in the example)

Orchard CMS Lists - how to replicate using Taxonomies

I'm new to Orchard but from various blog posts and SO answers it seems that Lists would help me achieve what I want. Unfortunately it seems that Lists have now been deprecated.
The documentation at http://docs.orchardproject.net/Documentation/Creating-lists suggests using Taxonomies instead. Is it possible to achieve the functionality of a List using Taxonomies?
You can use taxonomies to produce a list of content items. Create your taxonomy, add some items to it, attach the taxonomy field to your content type, and select the taxonomy you want to be displayed in the content type settings. Create a content item with a taxonomy selected then go to the url:
/taxonomy-name/*selected-taxonomy-item*
and it should display a list of all items with that taxonomy selected.
However, lists were deprecated and replaced by Projections, I would recommend using these. They are part of core and can be enabled from the backend. You can then create a query with your projection uses. This query determines what items you want displaying. It is pretty nice and simple, just need to play around with it. Let me know if you need more details about it, or probably just googling Orchard Projections will produce some useful links if you need to do some more complex things with it

sharepoint - get items from lists in multiple webs

Let's say I have a site level feature that has a content type, and a web level feature that has a list instance with items of the previously mentioned content type. If I enable the web feature for 100+ different webs, so I get 100+ lists from the same list instance definition and content type, what's the fastest way to get items from all those lists? Iterating through the webs and getting list items for each list one by one is very slow.
Use Method Below.
SPSiteDataQuery
The fastest way (and only way in my opinion) is to use the search engine.
You can do queries like "contenttype:document" to search for document across lists.

Query list items based on what permissions they have

Don't know how to google for such, but is there a way to query all the items where
Permissions are unique to listitem
These unique permissions contains assignment for specific group X.
Old post, but still getting plenty of views and I can't find anywhere more relevant to say this. There are some shortcuts available now, and you can use CAML to return only items with unique permissions, just not using the HasUniqueRoleAssignments property.
Sharing/setting unique permissions on a list item adds hidden "Field" nodes ("SharedWithDetails" & "SharedWithUsers") to it's SchemaXml property, which you can filter with CAML:
<View><Query><Where><IsNotNull><FieldRef Name='SharedWithDetails' /></IsNotNull></Where></Query></View>
Incidentally, setting a unique permission on an Item also seems to add a flag to the List itself, which is presumably how the /_layouts/15/uniqperm.aspx page manages to return answers on biiiig sites so quickly (and the cryptically vague "Lists that may contain items with unique permissions" message). You use this additional XML to identify lists that (probably) contain Items with unique permissions, which is vastly more efficient than enumerating every Item in the List to find out if any of them had unique permissions. This is particularly valuable if your Site contains many Lists, or any large Lists.
This PnP PowerShell code returns all lists that (probably) have items with unique permissions:
Get-PnPList -Includes SchemaXml | ? {$_.SchemaXML -match "SharedWithDetails"}
And once you have the list, you can use Get-PnPListItem and the above CAML query to efficiently return only the Items with unique permissions without having to enumerate/load every item in the List:
Get-PnPListItem -List [YourList] -Query "<View><Query><Where><IsNotNull><FieldRef Name='SharedWithDetails' /></IsNotNull></Where></Query></View>"
You will have to loop through the items and inspect the permissions item per item and update them if relevant. The more items you have the longer it takes. So not really a great solution.
An other solution is using the credentials of a user that is only member of group x.
SharePoint automatically takes permissions into account. So if you connect to the list using that user, you should only get the items on which the user has permissions.
Use the NetworkCredentials class for doing this.
Then use a CAML query to update your items.
--W
I don't think you can do this by shaping a CAML query and using the SPQuery object to get the items in this way.
My thinking would be to get all items, and loop through them testing for the HasUniqueRoleAssignments and RoleAssignments properties.

Merging and querying multiple lists

I am still new to sharepoint and would like to know if it is possible to make a query that works across several lists. My list looks like this
Customers (id, name and so forth)
Orders ( id, order number, customer and some additional info)
OrderItems (id, name, price, description and so on)
I would like to create a view that will display the OrderItems grouped by Order which again will be grouped by Customer.
In pure .net code that is pretty easy but is it possible to implement it only using sharepoint lists?
Without custom code or third party components you would have only a few options. Using SharePoint Designer to create a Data View or creating a custom Query with some complex CAML which I'm not even sure is entirely possible.
Personally I would look more towards using Master Detail functionality using a combination of web part connections and filtering. By activating Enterprise features you have available a number of Filter Web Parts that should be able to be combined to filter lists to selected values.
Personally I have gone with custom code to bring back list data based on queries and then used the GetDataTable() method of the SPListItemCollection object. Once you have the list items in DataTables you have numerouse ways to sort filter and aggregate the information.
I should add to this that there is a great article on displaying information from a dataset using the SPGridView and SPMenuField. Once you have your DataTables you could establish relationships in a dataset to display the information using these controls:
http://blogs.msdn.com/powlo/archive/2007/02/25/displaying-custom-data-through-sharepoint-lists-using-spgridview-and-spmenufield.aspx
Connected web parts can do this...
I think SPD can do that.
If you do not want get yourself dirty, take a look at SharePoint List Collection, which is perfect to you.

Resources