2

Using the HP-Trim SDK, how do you search for a document by its reference number?

The alleged documentation refers to methods for straightforward searches:

SelectByPrefix
SelectFavorites
SelectByUserLabel
SelectNone
SelectAll
SelectByUris
SelectTopLevels
SelectThoseWithin

and a generic search:

records.SetSearchString(“createdOn:this week and assignee:me”);

but all I want to do is find a document by its index.

These don't work:

records.SetSearchString("recordNum: <RecordNumber>");
records.SetSearchString("recordNumber: <RecordNumber>");
records.SetSearchString("reference: <RecordNumber>"); 

Any suggestions?

mcalex
  • 6,628
  • 5
  • 50
  • 80

3 Answers3

2

Are you using the .NET SDK? If so you can grab a record by its record number like so (C# example):

using (Database db = new Database()) {
    db.Connect();
    Record record = new Record(db, "123456"); // Replace with record number

    // Do stuff with record
    Console.WriteLine(record.Title);
}

You aren't required to construct a 'formal search' as such.

CapBBeard
  • 978
  • 10
  • 22
  • 1
    I wish i had known about this three projects ago... Curse you, TRIM's documentation!!!! – Nacht Aug 03 '16 at 06:19
  • Good if the record exists. Returns "Could not find the Record matching the value '123456" if it doesn't. Try trimMainObjectSearch.SetSearchString($"number:{the_recordnumber}"). – Tahari Nov 17 '21 at 01:52
2

In case you're curious about the correct string search syntax, this would have worked:

records.SetSearchString("number: <RecordNumber>"); 
Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Rory
  • 21
  • 2
1

Using the COM SDK;

using (Database db = new Database()) {
    db.Connect();

    Records records = db.MakeRecords();
    records.SelectAll();

    records.FilterString = "number:<RecordNumber>";

    if (records == null || records.Count.Equals(0))
       return;

    Record existing = records.Item(0);
}
Irshad
  • 3,071
  • 5
  • 30
  • 51