ALARMus Acclaimed Contributor.
Acclaimed Contributor.
334 views

Multisearch from one search field

Is it possible to make search by several fields, but set in search form text only in one field.

For example search for CI in device table.

Put in some spacial field some value - and search using this value search by "part number", "serial number", ...

0 Likes
2 Replies
TomPowe Acclaimed Contributor.
Acclaimed Contributor.

Re: Multisearch from one search field

You could make a Wizard to do this.

0 Likes
Acclaimed Contributor.. Jacob Heubner Acclaimed Contributor..
Acclaimed Contributor..

Re: Multisearch from one search field

Not sure what happened there... 

What version of HPSM are you running?  We accomplished something like this by modifying the QueryHelper ScriptLibrary record.

 

function buildAppendQuery(filename,isexternalSearch) {
   /*
  	* QCCR1E90473 KM doc's URL is out of security control
  	* added by Zhang, Zhen-Qing
  	*/
    var aquery = "";	
    if (isexternalSearch && filename == "kmdocument") {
		aquery = buildExtKMDSearchPermissionSubQuery();
	}
	
	/*	2014-06-30 Release
	The following lines were added by J.Heubner to allow the user to search both the 
	cg.alias.array and the logical.name in the same search
	*/
	
	if (!isexternalSearch && (vars.$cg_enhancedSearch==true || vars.$cg_enhancedSearch=="true") && system.functions.exists("cg.alias.array", vars.$L_file)){
		var oldSql = "and (logical.name#\""+vars.$L_file.logical_name+"\""
		var newSql = "and ((logical.name#\""+vars.$L_file.logical_name+"\" or cg.alias.array#\""+vars.$L_file.logical_name+"\") "
		vars.$L_sql = system.functions.strrep(vars.$L_sql, oldSql, newSql)
		
		var oldSql = "and (logical.name like \""+vars.$L_file.logical_name+"\""
		var newSql = "and ((logical.name like \""+vars.$L_file.logical_name+"\" or cg.alias.array like \""+vars.$L_file.logical_name+"\") "
		vars.$L_sql = system.functions.strrep(vars.$L_sql, oldSql, newSql)
	
		var oldSql = "and (file.device,logical.name#\""+vars.$L_file.logical_name+"\""
		var newSql = "and ((file.device,logical.name#\""+vars.$L_file.logical_name+"\" or cg.alias.array#\""+vars.$L_file.logical_name+"\") "
		vars.$L_sql = system.functions.strrep(vars.$L_sql, oldSql, newSql)

		var oldSql = "and (file.device,logical.name like \""+vars.$L_file.logical_name+"\""
		var newSql = "and ((file.device,logical.name like \""+vars.$L_file.logical_name+"\" or file.device,cg.alias.array like \""+vars.$L_file.logical_name+"\") "
		vars.$L_sql = system.functions.strrep(vars.$L_sql, oldSql, newSql)
		
	}

	// END ---
	
	//if (vars.$externalSearch) vars.$externalSearch=false;
    // end QCCR1E90473
    
    var profile = profiles[filename];
    if (profile == null) {
        logger.debug("The file \"" + filename + "\" doesn't have any associated profile record.");
        return aquery;//"";
    }
    
    var varname = profile["variable.name"];
    var env = system.vars[varname];
    if (env == null) {
        logger.warn("Environment variable \"" + varname + "\" hasn't been initialized yet.");
        return aquery;//"";
    }

    var fieldname = profile["field.name"];
    var appendQuery = (env[fieldname] == null ? "" : env[fieldname]);
    
    /*
     * Here is something wired, the "append.query" in "Profile" should be a text string.
     * But the data type of attribute "append.query" in $G.ocmq.environment is a [C++ datum], 
     * it need to convert to javascript string (getText()), otherwise type mismatch error will occur 
     * (only string can do regex match);
     */
    if (appendQuery["getText"] != undefined)
        appendQuery = appendQuery.getText();

    return formatAppendQuery(appendQuery) + aquery;
}

On the device search screen, we added a checkbox to a variable $cg.enhancedSearch.  We've got a custom field on the CI records called 'cg.alias.array' because the same CI may be known by multiple names (for example, HP Service Manager has an alias of HPSM and Service Manager).  With the Enhanced Search checkbox selected, when the user performs the search, we hijack the query and change it from :
            logical.name#"Service Manager"
to:
            logical.name#"Service Manager" or cg.alias.array#"Service Manager"

 

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.