HPRM Service API - Finding all of the Document Record Types

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

Parents
  • Verified Answer

    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("">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: localhost:88/.../PropertyAndFieldHelp
    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

     

     

     

     

Reply
  • Verified Answer

    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("">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: localhost:88/.../PropertyAndFieldHelp
    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

     

     

     

     

Children
No Data