Version

Search.queryWithOptions

This method is used to search resources within a SharePoint site. Receives a number of parameters to refine the search.

Syntax

SPlus.Search.queryWithOptions (url, options, function (resources){
        for (var i=0; i < resources.length; i++) {//Loop the resources Array
            var resource = resources [i];//Getting a JSON object with the requested fields
            var title = resource['title']; //Getting one of the fields
            var properties = resource['properties']; //Getting the properties array
            for (var i=0; i < properties.length; i++){
            }
        //TODO: Implement what to do with each resource and its properties
        }
}, function (errorResponse){
        var error = errorResponse['error#displayValue']; //Getting the error
        //TODO: Implement how to handle errors
}, function (cancelResponse){
        //TODO: Implement how to handle a user’s cancel
});

Search.queryWithOptions Parameters

Parameter

Type

Description

url

String

URL to the SharePoint site.

options

JavaScript Object

The custom Object options includes optional information to be used in the query to the SharePoint list.

onSuccess callback function

Parameter

Description

function (resources)

Success callback function to be implemented, which retrieves the resources array containing JSON Objects with the results from the SharePoint site.

onError callback function

Parameter

Description

function (eResponse)

Error callback function to be implemented, which receives the eResponse JavaScript Object.

onCancel callback function

Parameter

Description

function (result)

Cancel callback function to be implemented.

Note

Note: When using the Search.queryWithOptions method, you may want to specify the scope. As scopes vary depending on the site, it is highly recommended that you first retrieve all scopes for a site using the Search.getScopes method.