Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Highlighted
Established Member.. colk
Established Member..
879 views

COM SDK - Counting number related records regardless of rec relationship type

Jump to solution

Hi All,

 

I have an old interface using the COM SDK on TRIM 7.12.

 

I am currently doing a search for a TRIM record using the AddRelatedRecordsClause method with a clause of (TheCurrentTrimRecord, TRIMSDK.rrRecordRelationship.rrIsAltIn) to try and count the number of related records already alternatively related within the current Trim record.
 
E.g
RelSrch.AddRelatedRecordsClause(TrimRecord, TRIMSDK.rrRecordRelationship.rrIsAltIn)
SearchRelatedRecordsAlreadySet = RelSrch.GetRecords()
NumberOfRelatedRecordsSet = SearchRelatedRecordsAlreadySet.Count
 
My question is, is there a way of counting the number related records regardless of the relationship type?

 

Thanks.

 

 

0 Likes
1 Solution

Accepted Solutions
Matt Bayliss Contributor.
Contributor.

Re: COM SDK - Counting number related records regardless of rec relationship type

Jump to solution

Hi colk,

 

If you have a look, the RecRelationship object has a RelatedRecord property, so something like:

 

var recrelationships = record.RecRelationships;

for (int i = 0; i < recrelationships.Count; i++)
{
    var relationship = recrelationships.Item(i);
    var relatedrecord = relationship.RelatedRecord;
    Console.WriteLine(relatedrecord.Number);
}

 

Matt.

 

0 Likes
5 Replies
Established Member.. colk
Established Member..

Re: COM SDK - Counting number related records regardless of rec relationship type

Jump to solution

I have also tried to use RelSearch.AddAllRelatedRecordsClause(TheCurrentTrimRecord) which does not seem to get all related records for TheCurrentTrimRecord, instead it gets the TheCurrentTrimRecord item.

 

Ultimately, I am trying to count the number of related records for a specific TRIM record, if there are any related records, see if any of the related record numbers equal a variable I set earlier.

 

This is what I have now which works perfectly but is only enumerating through the specific rrIsAltIn related record type and it appears the AddAllRelatedRecordsClause does not work in the same way?

 

RelSrch.AddRelatedRecordsClause(TrimRecord, TRIMSDK.rrRecordRelationship.rrIsAltIn)

SearchRelatedRecordsAlreadySet = RelSrch.GetRecords()

NumberOfRelatedRecordsSet = SearchRelatedRecordsAlreadySet.Count

 

If NumberOfRelatedRecordsSet > 0 Then

        RelatedRecordsCounter = 1

                Do

                    SearchRelatedRecord = RelSrch.GetNext

                    If SearchRelatedRecord.Number = (SomeNumber) Then

                        IsRelatedRecordSet = True

               Exit Do

                    End If

                    RelatedRecordsCounter = RelatedRecordsCounter + 1

 

                Loop While (RelatedRecordsCounter < NumberOfRelatedRecordsSet)

End If

0 Likes
EWillsey Acclaimed Contributor.
Acclaimed Contributor.

Re: COM SDK - Counting number related records regardless of rec relationship type

Jump to solution
Why not check the RecRelationships.Count property of the record?
---------
Erik
CMRamble.com
0 Likes
Established Member.. colk
Established Member..

Re: COM SDK - Counting number related records regardless of rec relationship type

Jump to solution

Hey, thanks for the reply!

 

That helps with the count of related records, but sorry I wasn't very clear.

 

I was actually in the middle of trying this when I noticed your post but once I have the number or related records, if there are one or more, I want to enumerate through the related records and see if any of the related record “record numbers” equal a particular record number as set earlier in my code. If it does, I want to set IsRelatedRecordSet = True. That's were I am really stuck unfortunately!

Is there any way I can use the RecRelationships to get the related records "record numbers" also?

0 Likes
Matt Bayliss Contributor.
Contributor.

Re: COM SDK - Counting number related records regardless of rec relationship type

Jump to solution

Hi colk,

 

If you have a look, the RecRelationship object has a RelatedRecord property, so something like:

 

var recrelationships = record.RecRelationships;

for (int i = 0; i < recrelationships.Count; i++)
{
    var relationship = recrelationships.Item(i);
    var relatedrecord = relationship.RelatedRecord;
    Console.WriteLine(relatedrecord.Number);
}

 

Matt.

 

0 Likes
Established Member.. colk
Established Member..

Re: COM SDK - Counting number related records regardless of rec relationship type

Jump to solution

Hey Matt, that worked a treat! thanks for the help

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.