PeterMarshall
New Member.
1285 views

HPRM Service API - Finding all of the Document Record Types

Jump to solution

We are writing a generic integration with RM 8.3 using the .NET Client Proxies to the Service API, at the moment this is at a Proof of Concept stage

I'm trying to create a record to upload a document, but I have a problem with the record create, specifcally around the RecordTypeRef

so for the example code in the documentation

Record record = new Record();
record.RecordType = new RecordTypeRef() { Uri = 2 };
record.Title = "my test record";

RecordsResponse response = trimClient.Post<RecordsResponse>(record);

foreach (Record rec in response.Results)
{
	Console.WriteLine(record.Title);
}

Notice that the ResourceTypeRef is has a hard-coded Uri of 2 - what I need to be able to do is via the ServiceAPI find all of the RecordTypes for a document, but I am stuggling to find out how.

The reasoning is that our application will be integrating with RM8 on a number of different sites, who will have different setups so we need to avoid hard coding specific types.

So can anyone tell me how to query the RecordTypes (ideally only those relevant to a document), via the Service API ?

In addition I have noticed that when I get an exception from the .NET Client Proxy I am getting a MessageBox from ServiceStack library - is there any way to suppress this and get the actual exception ?

Thanks.

Peter

0 Likes
1 Solution

Accepted Solutions
Highlighted
Matt Bayliss Super Contributor.
Super Contributor.

Re: HPRM Service API - Finding all of the Document Record Types

Jump to solution

Hi Peter,

You need to do a RecordTypes request to find all the recordtypes you're after. If you use the RM desktop client you can get a list of the record types, and press F7 to refine the search. Once it's filtered how you like, you can change the Editor to string to see the query string you need (like "active and hasElecDocSupport and behaviour:Document" that I use below).

The following sample lists all the active document based record types which can accept electronic attachments:

 

var trimClient = new TrimClient("http://localhost:88/HPRMServiceAPI");
trimClient.Credentials = System.Net.CredentialCache.DefaultCredentials;

var recTypesRequest = new RecordTypes
{
    // record types that are active, can accept electronic attachments, and are Document behaviour record types
    q = "active and hasElecDocSupport and behaviour:Document",
    Properties = new List<string> { "RecordTypeName" }
};
// more recordtype properties: http://localhost:88/HPRMServiceAPI/PropertyAndFieldHelp?Get=All&trimType=RecordType
var recTypesResponse = trimClient.Get<RecordTypesResponse>(recTypesRequest);

foreach(var rt in recTypesResponse.Results)
{
    Console.WriteLine("{0}: {1}", rt.Uri, rt.Name);
}

Console.ReadLine();

 

I don't have an answer about the ClientProxy / ServiceStack exceptions though - hopefully someone else does.

Cheers,

Matt

 

 

 

 

2 Replies
Highlighted
Matt Bayliss Super Contributor.
Super Contributor.

Re: HPRM Service API - Finding all of the Document Record Types

Jump to solution

Hi Peter,

You need to do a RecordTypes request to find all the recordtypes you're after. If you use the RM desktop client you can get a list of the record types, and press F7 to refine the search. Once it's filtered how you like, you can change the Editor to string to see the query string you need (like "active and hasElecDocSupport and behaviour:Document" that I use below).

The following sample lists all the active document based record types which can accept electronic attachments:

 

var trimClient = new TrimClient("http://localhost:88/HPRMServiceAPI");
trimClient.Credentials = System.Net.CredentialCache.DefaultCredentials;

var recTypesRequest = new RecordTypes
{
    // record types that are active, can accept electronic attachments, and are Document behaviour record types
    q = "active and hasElecDocSupport and behaviour:Document",
    Properties = new List<string> { "RecordTypeName" }
};
// more recordtype properties: http://localhost:88/HPRMServiceAPI/PropertyAndFieldHelp?Get=All&trimType=RecordType
var recTypesResponse = trimClient.Get<RecordTypesResponse>(recTypesRequest);

foreach(var rt in recTypesResponse.Results)
{
    Console.WriteLine("{0}: {1}", rt.Uri, rt.Name);
}

Console.ReadLine();

 

I don't have an answer about the ClientProxy / ServiceStack exceptions though - hopefully someone else does.

Cheers,

Matt

 

 

 

 

Micro Focus Expert
Micro Focus Expert

Re: HPRM Service API - Finding all of the Document Record Types

Jump to solution

Catching the exception should be OK as long as you catch the WebServiceException.

try
{

	Record record = new Record();
	record.Title = "test title";
	record.RecordType = new RecordTypeRef() { Uri = 9000000000 };
	trimClient.Post(record);
}
catch (ServiceStack.ServiceClient.Web.WebServiceException ex)
{
	Console.WriteLine(ex.ErrorMessage);
}
catch (Exception ex)
{
	Console.WriteLine(ex.Message);
}

Blog | Samples | HPE CM 9.3 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.