Highlighted
Marilou Trusted Contributor.
Trusted Contributor.
293 views

SDK: Search for a record where the record number is on a string

Using the SDK, is there a way to search for the record where the record number to search is contained on a string? Below are the example of strings:

  • S-0472-0115-01-00001 UC_Part1 - should search for S-0472-0115-01-00001
  • S-0436-0047-08 Team 546 - Dachau - should search for S-0436-0047-08

 

0 Likes
3 Replies
Quinton Bernhardt Honored Contributor.
Honored Contributor.

Re: SDK: Search for a record where the record number is on a string

This seems like a programming challenge rather than a CM Api challenge - if I am understanding the problem correctly.

 

var sample_numbers = new List<string> { "2-0115-01-00001 UC_Part1", "S-0436-0047-08 Team 546" };

foreach (var record_number in sample_numbers)
{
    
    Console.WriteLine($"Extracted Number: {record_number.Split(' ')[0]}");
}

 

Regards,
Quinton Bernhardt
Meniko Records Management Services
0 Likes
Marilou Trusted Contributor.
Trusted Contributor.

Re: SDK: Search for a record where the record number is on a string

Yes it is a programming challenge agree.

The record for search could be a list or just one. Here is an example of one record to search

string searchstring = "S-0115-01-00001 UC_Part1";

searchstring = Substring(0, 16);      // to extract the record number part on the string S-0115-01-00001

Record recInformation;
recInformation = (Record)m_TRIMDatabase.FindTrimObjectByName(BaseObjectTypes.Record, searchstring );

 

If there's a way not to use substring to extract the number from the string and let the api figure out that part from the string that will be great! Not that the record number length (not always 16) varies on record type

0 Likes
Micro Focus Contributor
Micro Focus Contributor

Re: SDK: Search for a record where the record number is on a string

Marilou,

Not sure if you are still having issues with this, but if your format is the same across all strings (there is a space following the record number). you can do it with an IndexOf https://docs.microsoft.com/en-us/dotnet/api/system.string.indexof?view=netframework-4.8 

string searchstring = "S-0115-01-00001 UC_Part1";

searchstring = Substring(0, searchstring.IndexOf(' '));      // to extract the record number part on the string S-0115-01-00001

Record recInformation;
recInformation = (Record)m_TRIMDatabase.FindTrimObjectByName(BaseObjectTypes.Record, searchstring );

 

Cheers,

Aaron

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.