Open Documentation Menu

Using the class “DocumentSearchOptions”

The class dvelop_docs_dev.DocumentSearchOptions defines the parameters used to retrieve documents from the connected document management system (DMS).

Signature
global with sharing class DocumentSearchOptions implements IDocumentSearchOptions
Contents
Constructors

You can create an instance of DocumentSearchOptions with the following constructors:

DocumentSearchOptions() 

This constructor creates a DocumentSearchOptions instance with default values.

Signature 
global DocumentSearchOptions()
Methods

The class DocumentSearchOptions provides the following methods:

buildOptions()

This method creates an instance of the class DocumentSearchOptions.Builder.

Note

You can find a detailed guide to using the DocumentSearchOptions.Builder class here

Signature
global static DocumentSearchOptions.Builder buildOptions()
Returned entry

A new instance of dvelop_docs_dev.DocumentSearchOptions.Builder.

useRecordContext(recordId)

This method changes the context of the search for the record with the transferred ID.

All the settings, such as mappings, document type assignments, property assignments and sorting settings, are then determined based on the object types and the record type of the transferred record.

Note

Using this method overrides the prior use of the following methods:

  • useObjectContext(objectApiName) 

  • useObjectContext(objectApiName, recordTypeId) 

You should only ever use one of the available methods.

Signature
global void useRecordContext(Id recordId)
Parameters

recordId: The ID of the record to be used as the context for the search.

Data type: Id

useObjectContext(objectApiName)

This method changes the context of the search to the Salesforce object with the transferred API name.

All the settings, such as mappings, document type assignments, property assignments and sorting settings, are then determined based on the transferred item and the standard record type Master.

Note

Using this method overrides the prior use of the following methods:

  • useObjectContext(objectApiName) 

  • useObjectContext(objectApiName, recordTypeId) 

You should only ever use one of the available methods.

Signature
global void useObjectContext(String objectApiName)
Parameters

objectApiName: The API name of the Salesforce object to be used as the context for the search. 

Data type: String

useObjectContext(objectApiName, recordTypeId)

This method changes the context of the search to the Salesforce object with the transferred API name and the record types with the transferred ID.

All the settings, such as mappings, document type assignments, property assignments and sorting settings, are then determined based on the transferred object and the transferred record type.

Note

Using this method overrides the prior use of the following methods:

  • useObjectContext(objectApiName) 

  • useObjectContext(objectApiName, recordTypeId) 

You should only ever use one of the available methods.

Signature
global void useObjectContext(String objectApiName, String recordTypeId)
Parameters
  • objectApiName: The API name of the Salesforce object to be used as the context for the search. 

    Data type: String

  • recordTypeId: The ID of the record type to be used as the context for the search.

    Data type: String

addSearchAttribute(attributeKey, value)

This method adds a user-defined search attribute with a corresponding value to the existing search attributes.

You can define any number of properties and values for the search, which limit the result of the search to documents with matching properties.

Note

Using this method overrides the following global settings:

  • Mapping 

  • Properties > Mappings 

Signature
global void addSearchAttribute(String attributeKey, String value)
Parameters
  • attributeKey: The key of the property to be used for the search. You can find a full overview of the available keys under Properties > Mappings in your d.velop documents configuration.

    Data type: String

  • value: The value of the property that is synchronized with the properties of the documents. 

    Data type: String

addSearchAttribute(attributeKey, values)

This method adds a user-defined search attribute with a list of corresponding values to the existing search attributes.

You can define any number of properties and values for the search, which limit the result of the search to documents with matching properties.

Note

Using this method overrides the following global settings:

  • Mapping 

  • Properties > Mappings 

Signature
global void addSearchAttribute(String attributeKey, List<String> values)
Parameters
  • attributeKey: The key of the property to be used for the search. You can find a full overview of the available keys under Properties > Mappings in your d.velop documents configuration.

    Data type: String

  • values: A list of possible values for the property that is synchronized with the properties of the documents. The values have an OR link. If one value matches, a document is found. 

    Data type: List<String>

addSearchAttributes(searchAttributes)

This method adds multiple search attributes and values for the search to the existing search attributes.

You can define any number of properties and values for the search, which limit the result of the search to documents with matching properties.

Note

Using this method overrides the following global settings:

  • Mapping 

  • Properties > Mappings 

Signature
global void addSearchAttributes(Map<String, String> searchAttributes)
Parameters

searchAttributes: A collection of key-value pairs for search properties. 

Data type: Map<string, string>

ignoreSearchAttributes()

This method ignores all the global search attributes and all the user-defined search attributes added previously using the addSearchAttribute or addSearchAttributes methods.

Note

Using this method overrides the following global settings:

  • Mapping 

  • Properties > Mappings 

Using this method nullifies the effect of the following methods, regardless of the order of use:

  • addSearchAttribute 

  • addSearchAttributes 

Signature
global void ignoreSearchAttributes()
addSearchCategory(categoryKey)

This method adds a user-defined search category to the existing search categories.

You can define any number of search categories, which limit the result of the search to documents with matching categories.

Note

Using this method overrides the following global settings:

  • Document Types > Assignment 

  • Document Types > General Settings > Search only selected document types 

Signature
global void addSearchCategory(String categoryKey)
Parameters

categoryKey: The key of the category to be used for the search. You can find a full overview of the available keys under Document Types > Assignment in your d.velop documents configuration. 

Data type: String

addSearchCategories(categoryKeys)

This method adds multiple search categories to the existing search categories.

You can define any number of search categories, which limit the result of the search to documents with matching categories.

Note

Using this method overrides the following global settings:

  • Document Types > Assignment 

  • Document Types > General Settings > Search only selected document types 

Signature
global void addSearchCategories(List<String> categoryKeys)
Parameters

categoryKeys: A list of keys for search categories. 

Data type: List<String>

ignoreSearchCategories()

This method ignores all the global search categories and all the user-defined search categories added previously using the addSearchCategory or addSearchCategories methods.

Note

Using this method overrides the following global settings:

  • Document Types > Assignment 

  • Document Types > General Settings > Search only selected document types 

Using this method nullifies the effect of the following methods, regardless of the order of use:

  • addSearchCategory 

  • addSearchCategories 

Signature
global void ignoreSearchCategories()
hideFolders()

This method hides folders in the search results.

Note

Using this method overrides the following global settings:

  • Document List > General Settings > Show Folders 

This method has an effect only if folders can actually be identified with a search. The following prerequisites apply:

  • Document Types > General Settings > Search only selected document types is deactivated

  • Document Types > General Settings > Search only selected document types is activated and search categories added with Document Types > Assignment contain folders

  • Document Types > General Settings > Search only selected document types is activated and search categories added with the method addSearchCategory or addSearchCategories contain folders

Signature
global void hideFolders()
showFolders()

This method shows folders in the search results.

Note

Calling this method overwrites the following global settings:

  • Document List > General Settings > Show Folders 

This method has an effect only if folders can actually be identified with a search. The following prerequisites apply:

  • Document Types > General Settings > Search only selected document types is deactivated

  • Document Types > General Settings > Search only selected document types is activated and search categories added with Document Types > Assignment contain folders

  • Document Types > General Settings > Search only selected document types is activated and search categories added with the method addSearchCategory or addSearchCategories contain folders

Signature
global void showFolders()
sortByAttribute(attributeKey)

This method adds the property with the transferred key as a sorting attribute. The result of the search is then sorted based on the values of the specified property. The sorting is in ascending order by default.

Signature
global void sortByAttribute(String attributeKey)
Parameters

attributeKey: The key of the property to be used to sort the search results. 

Data type: String

sortAscending()

This method sorts the search results in ascending order based on the sorting attribute defined using the sortByAttribute method.

Note

This method only has an effect if you have also defined a sorting attribute using the sortByAttribute method.

Signature
global void sortAscending()
sortDescending()

This method sorts the search results in descending order based on the sorting attribute defined using the sortByAttribute method.

Note

This method has an effect only if you have also defined a sorting property using the method sortByAttribute.

Signature
global void sortDescending()
setSearchText(searchText)

This method searches for the transferred search term in all the documents and via a full-text search and restricts the results to matching documents.

Signature
global void setSearchText(String searchText)
Parameters

searchText: The search term for the full-text search. 

Data type: String

setMaxAgeInDays(maxAgeInDays)

This method sets a maximum age (in days) for the search. Any documents that are older than the specified number of days are not included in the search.

Signature
global void setMaxAgeInDays(Integer maxAgeInDays)
Parameters

maxAgeInDays: The maximum age of the documents in days. 

Data type: Integer

setPageIndex(pageIndex)

This method sets the page number of the documents in the search result. The number of pages available is defined by the number of all the available documents and the page size defined using the setPageSize method.

Signature
global void setPageIndex(Integer pageIndex)
Parameters

pageIndex: The number/index of the page. The starting index is one.

  • Data type: Integer

  • Default value: 1

setPageSize(pageSize)

This method sets the page size and thus determines the maximum number of documents in the search result.

Signature
global void setPageSize(Integer pageSize)
Parameters

pageSize: The maximum number of documents per page.

  • Data type: Integer

  • Default value: 100

Use

The following section shows you some application scenarios depicting the correct use of the class.

Identifying all the documents for a data record (with global settings)

dvelop_docs_dev.DocumentSearchOptions searchOptions = new dvelop_docs_dev.DocumentSearchOptions();
searchOptions.useRecordContext('001AP000003aVJhYAM');

Identifying all the documents for accounts (without global settings)

dvelop_docs_dev.DocumentSearchOptions searchOptions = new dvelop_docs_dev.DocumentSearchOptions();
searchOptions.useObjectContext('Account');
searchOptions.ignoreSearchAttributes();
searchOptions.ignoreSearchCategories();

Identifying all the documents for accounts with a matching “accountnumber” property, “Schriftverkehr Kunde” (customer correspondence) or “Unbestimmte Dokumentart” (unspecified document type) document type, without folders

dvelop_docs_dev.DocumentSearchOptions searchOptions = new dvelop_docs_dev.DocumentSearchOptions();
searchOptions.useObjectContext('Account');
searchOptions.addSearchAttribute('accountnumber', '001AP000003aVJhYAM');
searchOptions.addSearchCategory('Schriftverkehr_Kunde');
searchOptions.addSearchCategory('Unbestimmte_Dokumentart');
searchOptions.hideFolders();

Complex use case

dvelop_docs_dev.DocumentSearchOptions searchOptions = new dvelop_docs_dev.DocumentSearchOptions();
searchOptions.useRecordContext('001AP000003aVJhYAM');

searchOptions.addSearchCategories(new List<String>{ 'Schriftverkehr_Kunde','Eingangsrechnung', 'Unbestimmte_Dokumentart' });
searchOptions.addSearchAttributes(
    new Map<String, String>{
		'accountnumber', '001AP000003aVJhYAM',
		'objecttitle' => 'Testaccount',
		'published' => 'Ja'
	}
);

searchOptions.sortByAttribute('createddate');
searchOptions.sortAscending();

searchOptions.setSearchText('Produkt');
searchOptions.setMaxAgeInDays(1);
searchOptions.setPageIndex(1);
searchOptions.setPageSize(500);