How To: Write a URL that searches multiple fields at once in a given workspace using JoinRules

Version 1

    When creating a URL to search a given workspace, the AND and OR JoinRules are available to allow for more robust searches to include multiple fields. This article explains in more detail how to utilize these JoinRules in the URL structure to achieve the desired search results.

     

    For more information on creating URLs to log in or access workspaces, please see the article, "Logging In or Accessing Records Using URLs" in the online product documentation for Ivanti Service Manager at: https://help.ivanti.com/

     

    ----

     

    For this search URL:

    https://tenant_URL/Login.aspx?Scope=ObjectWorkspace&CommandId=Search&ObjectType=Employee%23&CommandData=FirstName,%3D,0,Green,string|

    The system will log in, select the Employee workspace, and search the FirstName field for the string value "Green"

     

    In some environments, searching a single field for a single value will return a less than ideal number of records. Thus being able to search more than one field at the same time, as in the in-application search function, proves to be a powerful tool. To accomplish this in the URL, the JoinRules must be applied. The options are AND and OR.

     

    To search for an employee who has the first name Green AND the first name of Number, our search URL might look like this:

    https://tenant_URL/Login.aspx?Scope=ObjectWorkspace&CommandId=Search&ObjectType=Employee%23&CommandData=FirstName,%3D,0,Green,string,AND|LastName,%3D,0,Number,string,AND|

     

    Or to search for an employee who has a first name of Green or a first name of Red:

    https://tenant_URL/Login.aspx?Scope=ObjectWorkspace&CommandId=Search&ObjectType=Employee%23&CommandData=FirstName,%3D,0,Green,string,OR|FirstName,%3D,0,Red,string,OR|

     

    To fully explain how the URL is creating the search within the UI, we need to break it apart.

     

    Example search URL from above:

    https://tenant_URL/Login.aspx?Scope=ObjectWorkspace&CommandId=Search&ObjectType=Employee%23&CommandData=FirstName,%3D,0,Green,string,AND|LastName,%3D,0,Number,string,AND|

     

    Everything before "CommandData" is related to logging in and navigating to the given workspace. "CommandData" is similar to a WHERE clause, and everything after the %3D (this is an escaped = symbol, as described in the above referenced help file) are the search terms.

    So this section of the URL: CommandData=FirstName,%3D,0,Green,string,AND|LastName,%3D,0,Number,string,AND|

    Can be read as: "WHERE FirstName(stringField) is equal to 'Green' AND LastName(stringField) is equal to 'Number'"

     

    It is important to note that the JoinRule preceding the pipe symbol, either AND| or OR|, belongs to the search terms also preceding the pipe symbol.

    For example:

    CommandData=FirstName,%3D,0,Green,string,AND|LastName,%3D,0,Number,string,AND|

    CommandData=FirstName,%3D,0,Green,string,OR|FirstName,%3D,0,Red,string,OR|

     

    CommandData=FirstName,%3D,0,Red,string,OR|LastName,%3D,0,Colour,string,AND|

     

    To further illustrate this concept, this URL will search for an employee who has a first name of Green OR a first name of Red AND a last name of Colour.

     

    https://tenant_URL/Login.aspx?Scope=ObjectWorkspace&CommandId=Search&ObjectType=Employee%23&CommandData=FirstName,%3D,0,Green,string,OR|FirstName,%3D,0,Red,string,OR|LastName,%3D,0,Colour,string,AND|

     

    Happy searching!