Difference between revisions of "SearchContext Class"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
 
Line 3: Line 3:
===Creating a SearchContext Object===
===Creating a SearchContext Object===
Use the setters and getters in the [{{DOCHOST}}/javadocs/com/platform/api/SearchContext.html SearchContext] class to set up the query. (The syntax for each part is identical to that used with the REST APIs to create a  [[REST_API:Dynamic_Search|Dynamic Search]]. The only difference is that you don't have to concatenate them all into a single string.)
Use the setters and getters in the [{{DOCHOST}}/javadocs/com/platform/api/SearchContext.html SearchContext] class to set up the query. (The syntax for each part is identical to that used with the REST APIs to create a  [[REST_API:Dynamic_Search|Dynamic Search]]. The only difference is that you don't have to concatenate them all into a single string.)
[{{DOCHOST}}/javadocs/com/platform/api/SearchContext.html SearchContext]


=== Using the SearchContext Object ===
=== Using the SearchContext Object ===

Latest revision as of 05:55, 13 December 2021

This class is designed for large, complex queries. Using it, you can formulate a search query one part at a time, and have each part validated independently, rather than putting the entire query in one long string and having it validated all at once.

Creating a SearchContext Object

Use the setters and getters in the SearchContext class to set up the query. (The syntax for each part is identical to that used with the REST APIs to create a Dynamic Search. The only difference is that you don't have to concatenate them all into a single string.)

Using the SearchContext Object

These APIs take a SearchContext object:

  • Functions.searchRecords(SearchContext searchContext)
  • Functions.searchGlobalPicklists(SearchContext searchContext)
  • Functions.searchPackages(SearchContext searchContext)
  • Functions.searchSocialFeeds(SearchContext searchContext)
  • Functions.searchSocialGroups(SearchContext searchContext)

Learn more: Uses recorded in the Javadocs

Example

<syntaxhighlight lang="java" enclose="div">

SearchContext searchContext = new SearchContext();

searchContext.setFieldList("*"); searchContext.setObjectId(""); // For a record search: objectName or ID searchContext.setPage(0); searchContext.setPageSize(5000); searchContext.setFilter("title contains 'Order' "); // Criteria searchContext.setSortBy("date_created"); searchContext.setSortBy2("title"); searchContext.setSortOrder("DESC"); searchContext.setSortOrder2("ASC");

List<GlobalPicklistBean> results; results = Functions.searchGlobalPicklists(searchContext); </syntaxhighlight>