ObjectCommon.Search Function (System.Collections.Generic.IList<Authorit.API.Dto.ObjectSearchCriteria>, Authorit.API.Dto.ObjectListSort, Authorit.API.Dto.SortDirection) - Author-it On-Premises - Author-it

Author-it Development Documentation

Search objects in the library database, then apply sort to results.

Parameters

criteria - List of ObjectSearchCriteria to filter search by.

sortBy - Field(s) to sort results by.

sortDirection - Direction to sort.

Returns

A list of instances of the ObjectBrief class that contain information about the objects.

Notes

Each ObjectSearchCriteria adds a new filter to the object search, the filters combine with a logical AND. The value field for each criteria is interpreted differently depending on the ObjectSearchField set for the criteria:

ObjectSearchField

Value Format

Value Example

Search Behavior

ContainingText

String

"some text"

A free form text search of an objects text (description, headings, topic text etc.). This behaves the same as the "Containing Text" search in Author-it client software.

Description

String

"object description"

"Description" field of an object.

ObjectCode

Integer

"44455"

Object Code of an object to search for.

FolderId

Integer

"12"

Folder ID of a folder to search for objects in.

InBookId

Integer

"43"

Object ID of a book to search the table of contents of.

ResolveSubBooks

Boolean

"true", "false"

Works in conjunction with "InBookId": if set to true, then sub-books will be resolved for a "InBookId" search.

BasedOnId

Integer

"4422"

Object ID of the template an object is based on.

BasedOnDescription

String

"template description"

"Description" field of the template an object is based on.

ObjectType

Integer (ObjectType Enum)

"1" (Book), "2" (Topic)

Type of object to search for. Accepts the integer associated with the ObjectType enum.

ReleaseStateId

Integer

"12"

Release State ID to search for objects that are in.

IsTemplate

Boolean

"true", "false"

Search for templates, or normal objects only.

ModifiedFromDate

DateTime

"12-Mar-2010", "12-Mar-2010 10:00am"

Objects last modified on, or after supplied date.

ModifiedToDate

DateTime

"14-Mar-2010", "14-Mar-2010 10:00am"

Objects last modified on, or before supplied date.

VariableAssignment

Complex

"<PRODUCT_NAME>", "<PRODUCT_NAME>=VALUE"

A variable assignmened (with optional value) to an object. The Variable can be specified by name (with, or without angle-brackets) or numerical ID. If the assignment value is numerical then assigned objects will be searched by ID in addition to text assignments.

Sample VB Code:

' Uses the Search to return a sorted list of all books that aren't templates

' and populates a ListBox with them

Private Sub LoadBooksIntoListbox(ByVal ObjectService As API.Services.ObjectCommon, _

ByVal ListBox As ListBox)

' Create a list of criteria for the search

Dim criteria As New List(Of API.Dto.ObjectSearchCriteria)

' Criteria 1: look for only books

Dim criteriaBooks As New API.Dto.ObjectSearchCriteria

criteriaBooks.Field = API.Dto.ObjectSearchField.ObjectType

criteriaBooks.Value = API.Dto.ObjectType.Book.ToString

criteria.Add(criteriaBooks)

' Criteria 2: exclude templates

Dim criteriaIsTemplate As New API.Dto.ObjectSearchCriteria

criteriaIsTemplate.Field = API.Dto.ObjectSearchField.IsTemplate

criteriaIsTemplate.Value = "false"

criteria.Add(criteriaIsTemplate)

' Use ObjectService.Search to return a list of books that aren't templates,

' sorted by book description ascending

Dim books As List(Of API.Dto.ObjectBrief) = ObjectService.Search(criteria, _

API.Dto.ObjectListSort.Description, _

API.Dto.SortDirection.Ascending)

' Iterate through the search results adding each book into the ListBox

For Each book As API.Dto.ObjectBrief In books

ListBox.Items.Add(String.Format("({0}) {1}", book.ObjectId, book.Description))

Next

End Sub