Highlighted
Regular Contributor.
Regular Contributor.
248 views

TrimMainObjectSearch search clauses

hello

 

i have a TrimMainObjectSearch that searchs for records . i want to include 2 search clauses for this record search. 

  1.  search given the record title
  2. and search given the record's parent classification name.

i was able to make it using 1 search clause but when it happens to add another one search clause to filder my search i cant make it. 

 

here is my code

TrimMainObjectSearch tMoS = new TrimMainObjectSearch(HPRMdb, BaseObjectTypes.Record);
TrimSearchClause searchClause1 = new TrimSearchClause(HPRMdb, BaseObjectTypes.Record, SearchClauseIds.RecordTitle);
//sparent = "RRL"
searchClause1.SetCriteriaFromString(sParent);
TrimSearchClause searchClause2 = new TrimSearchClause(HPRMdb, BaseObjectTypes.Record, SearchClauseIds.ClassificationTitle);
//sClient= some classification keyword name
searchClause2.SetCriteriaFromString("*" + sClient + "*");
tMoS.AddSearchClause(searchClause1);
tMoS.And();
tMoS.AddSearchClause(searchClause2);

 

the bold letter line is the line when i am getting the following exception error

{"The search method title is not relevant for Records."}

 

any ideas how i could implement such search including search clauses for record name and parent classification name ??

 

 

0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TrimMainObjectSearch search clauses

What you need is actually a sub search.  You are attempting to use SearchClauseIds.ClassificationTitle  to do a record search when what you need is a Record search with a classification sub search.

I attempted to write some sample code using the TrimSearchClause methods just as you have but I found a bug in the sub search routine.  I am using the latest build, not a release build so this bug may not be in the wild yet.

Anyway, even though there are advantages to using the TrimSearchClause method I also like the string searching.

The code below will find all Records with the word 'Flat' in the title which have a Classifiation with the work 'Accommodation' in the title.

 

var search = new TrimMainObjectSearch(database, BaseObjectTypes.Record);
search.SetSearchString("recTitle:Flat and recClassification:[plnWord:Accommodation]");

foreach (Record record in search)
{
	Console.WriteLine(record.Title);
}

 

If you wanted to search for the exact title then use the title search, not the word search, for example:

search.SetSearchString("recTitle:Flat and recClassification:[plnTitle:Accommodation - Domestic - General]");

 

I prefer to use the internal names for search clauses (e.g. recTitle) as it avoids issues with captioning and localisation.

As you will see when you look at the search string the square brace indicates a sub search.


Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
Highlighted
Regular Contributor.
Regular Contributor.

Re: TrimMainObjectSearch search clauses

Thanks for the quick response. i used the setSearchString method as you descriped and it did the trick.

 

now i would like to seach for a classification having 2 classification conditions based on classification title .

 

i tried the following without any luck

 

TrimMainObjectSearch recordSearch = new TrimMainObjectSearch(HPRMdb, BaseObjectTypes.Classification);

  1. recordSearch.SetSearchString(Classification:[plnWord: E03096A])
  2. recordSearch.SetSearchString(recClassification:[plnWord: E03096A])

any further sugestions ??

also i read that the TRIM HELP documentation gives a comprehensive description of the Query String formatting rules.

do you know where i could find such documentation ??

 

kind regards

 

Tags (1)
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TrimMainObjectSearch search clauses

Try something like this:

 

search.SetSearchString("recClassification:[plnWord:Accommodation or plnWord:Accounting]");

 

Calling SetSearchString a second time will overwrite whatever you set the first time you called it.

 

I do not use the help enough to know where the search string syntax is documented, but I wrote a post on how I compose search strings.


Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Re: TrimMainObjectSearch search clauses

another question i have

 

i want to move a classification from parent A to parent B 

 

am using the moveClassification method but am getting the following error  ( error allocatiing new number for classification , the number already exists )due to the fact that numbering on the new parents sequence is reserved.  tried the followng

  1. found new parent last child number
  2. assign to classification the LastchildNo +1 as  the new levelNumber
  3. moveclassification

but again failed because it updated only the levelnumber and not the whole NumberId. i check the number Id property and it is a readonly property. any ideas on how i could fully upodate the numbering and call successfully the moveclassification method ??

 

levelnumber

aeleftheriou32_0-1589190649791.jpeg

 

full numberId

aeleftheriou32_1-1589190662425.jpeg

 

 

 

 

 

 

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Re: TrimMainObjectSearch search clauses

a kind reminder to my last question ?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TrimMainObjectSearch search clauses

You might need to lodge a support request as I am not sure how best to approach this.


Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
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.