Highlighted
Absent Member.. b460 Absent Member..
Absent Member..
417 views

Checking if location has access to record / record type using COM SDK

Hi,

 

I was wondering if it is possible to check if a location has access to a particular record or record type? If so could you please direct me as to which methods would do this.

 

We have an issue at the moment where if the location does not have access to the record then accessing any of the members of that record ends in a as the object is never initialised. For example:

 

Dim recType As TRIMSDK.RecordType = db.GetRecordType(CType("Administrative Files", String))

Dim recSearch As TRIMSDK.RecordSearch = db.NewRecordSearch

recSearch.RawSearch(rawString)

recSearch.FilterRecordType(recType)

Dim records As TRIMSDK.Records = recSearch.GetRecords
Dim record As TRIMSDK.Record

If records.Count > 0 Then

   For count As Integer = 0 To recsCount - 1
     'If location does not have access to the record or the record type then record fails to initialise and returns a "Object reference not set to an instance of an object" error
     record = records.Item(count)
   Next

End If

 

Would be great if someone can advise how to get around this. If the location has access then the code works fine.

 

Thanks.

 

 

2 Replies
EWillsey Acclaimed Contributor.
Acclaimed Contributor.

Re: Checking if location has access to record / record type using COM SDK

The record collection doesn't validate access controls until you hit the object.  So don't use a For Loop.  Use a do while loop.

 

 

Dim tRecords as TRIMSDK.Records

Set tRecords = tSearchResults.GetRecords

Dim tRecord as TRIMSDK.Record

Set tRecord = tRecords.Next

do while ( Not tRecord is Nothing )

   '' do something here
   Set tRecord = tRecors.Next

loop

---------
Erik
0 Likes
Absent Member.. b460 Absent Member..
Absent Member..

Re: Checking if location has access to record / record type using COM SDK

Thanks, I'll try this out.

 

I'm currently testing if the user location has access to a record type using the condition:

 

If Not (recType.AccessControl.Contains("denied")) Then

...

End If

 Is there another formal way to test this rather than checking if the access control text contains "denied"?

 

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.