Highlighted
Respected Contributor.
Respected Contributor.
332 views

Using string queries in WebAPI

Hi All,

I have been trying to execute a string query with multiple conditions using HPRM WebAPI but don't seem to find an appropriate method for execution.

I was able to so this using HPRM SDK using the 'SetSearchString()' method. Is there any similar method avaiable for WebAPI ?

//Old code
TrimMainObjectSearch searchObject = new TrimMainObjectSearch(hprmConnect, BaseObjectTypes.Record);
searchObject.SetSearchString(query);

To give more insights, the query I am trying to execute will have multiple conditions

eg.  "(customProperty = '<some value>' ) and (idol:'<some search word/words>')" 

I found the following methodology but it does not execute multiple conditions, especially the idol queries

// this does not work properly 
searchStack.Add(
new TrimSearchClause()
{
IsSearchClause = true,
CriteriaString= "createdOn>=1/09/2017 and  idol:test"
});

 regards,

Rohan

Tags (1)
0 Likes
1 Reply
Highlighted
Super Contributor.
Super Contributor.



Hi Rohan,

I'm not a pro at using the ServiceAPI, however, it looks like you are placing two criteria in one clause.

Perhaps something like this:

 

searchStack.Add(
  new TrimSearchClause()
  {
IsSearchClause = true, CriteriaString = "createdOn>=1/09/2017" });

searchStack.Add(
new TrimSearchClause()
{
IsSearchClause = true,
CriteriaString = "idol:test
};

 Or the AddRange() equivalent if it's supported.

 

 

0 Likes
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.