Toggle menu

Searching for iCM Content

The form related to this article demonstrates one way in which you can work with the results you get back from the API Server and iCM API worker.

The worker is called server-side as the HTML template on page 2 of the form loads.

function(helper, defaultValue, currentValue) {
    let searchText = helper.queryFieldValue("PAGE1", "SEARCHTEXT");
    let resp = helper.utilServerAPIServerCall("icmapi", "CSSearchMultiple_get", {
        "set": {
            "CollectionNameList": "Article",
            "RootArticleIDs": "8540,8550,8555,8560,7350,3130",
            "LuceneRepositoryPath": "http://localhost:5506/solrsite",
            "Keywords": searchText
        "get": "Key,Title"
    }, {
        "rawMode": true

CSSearchMultiple_get takes the value of the field on page one as the "Keywords" parameter. The search is limited to the article collection, and those articles beneath article 3029 (the ID of the homepage of this knowledge base subsite).

The get request only retrieves the article ID and title. Using "*" would return all of the information held in the search index, but would be slower.

The return statement limits the result to the data we're interested in.

Results are displayed using the field's Handlebars template.

{{#if multipleItemData}}
    <p>Searching on <strong>{{FIELD "SEARCHTEXT"}}</strong> found <strong>{{length multipleItemData}}</strong> results.</p>
                <th>Article ID</th>
            {{#each multipleItemData}}
                    <td><a href="./{{Key}}">{{Title}}</a>
    <p>Sorry, <strong>{{FIELD "SEARCHTEXT"}}</strong> didn't match any articles.</p>

This template uses the standard {{#if}} helper, to display a table of results if the response form the API Server includes multipleItemData. If it doesn't the {{else}} message is displayed.

As well as displaying the Key and Title from the results, it also uses the length helper to count the number of results, and the iCM form library's {{FIELD}} notation to query the value of the SEARCHTEXT field on page 1.

Last modified on 02 August 2023

Share this page

Facebook icon Twitter icon email icon


print icon