Domanda

I am new to Search Query Tool,

I have a team site, which contain multiple list with the same content type named "Ticket",

The first problem i have encountered, is I need to collect all the items from all these lists (which are similar and have the same Content Type), into one place in order to use them as a Data source for reporting later.

So I found that i can work with Search Query Tool, which enable you to create an endpoint and collect in it what you desire.

enter image description here

Question: How can I build a query that get all the items with the ContentType=Ticket ?

È stato utile?

Soluzione

You'll need to first look up the ContentTypeID of your ContentType. There are multiple ways to find the ID of a site-level Content Type: using the REST API, using PowerShell, or carefully parsing it from the URL query string after you browse to that ContenType's config page in the browser.

Once you have that ID, you have to understand that every time you add that ContentType to a List or Library, SharePoint technically creates its own derived type from the site-level type by appending additional numbers on to the end of the ID to ensure it is unique. So, you will want to append the wildcard character to the end for your search query to find all derived uses of your ContentType, such as querytext='ContentTypeId:YourSiteContentTypeIdHere*'

For example, if your ContentType ID is 0x0100AEC702D446F8F04696C2B7573837C451, then the following query would get all items from all lists that are using a content type derived from that type:

https://bbsdz.sharepoint.com/_api/search/query?querytext='ContentTypeId:0x0100AEC702D446F8F04696C2B7573837C451*'

Altri suggerimenti

It the content type name is "Ticket" you can use a contains query like ContentType:Ticket. The ContentType Managed Property is populated with the name of the content type. Sometimes it have spaces padding it so I have found contains (using the colon) works best.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top