Community
Showing results for 
Search instead for 
Do you mean 
Reply

Filter Custom Sub Entity

Loyal Listener
Posts: 69
Country: United States

Filter Custom Sub Entity

I'm looking for any code samples or snippets to include addtional filtering for a custom sub entity (in this case attached to a group.)  Specifically I'm trying to filter the rows by Record Manager (so a current user will see only their records) but I'll take any filtering examples that might be available.

 

Thanks.

 

Mike Fortier

Fortier Consulting, LLC

mike@fortierconsulting.com

Copper Contributor
Posts: 87
Country: USA

Re: Filter Custom Sub Entity

Mike,

Hope this helps.  It references a few of my personal functions (such as GetCustomEntityFieldDescriptor), but you should be able to subtitute them out pretty easily.  I also cut out bunch of repetitive conditions/code in the middle, which didn't illustrate anything new.:

 

 

    Private Sub FilterList()

        Dim ContactList As Act.Framework.Contacts.ContactList
        Dim fCriteria As Act.Framework.IFilterCriteria()
        Dim fCriteriaIndex As Integer
        Dim field As Act.Framework.CustomEntities.CustomEntityFieldDescriptor
        Dim FilterCount As Integer

        Dim sCriteria As SortCriteria()

 

        sCriteria = New SortCriteria() _
                    {New SortCriteria(manager.GetCustomEntityFieldDescriptor( _
                        "JOB_ORDER_NBR", _
                        Act.Framework.MutableEntities.FieldNameType.[Alias]), _
                        System.ComponentModel.ListSortDirection.Descending)}

 

        FilterCount = 0

 

        If rbActive.Checked Then FilterCount += 1

        If cboJobCity.Text <> "" Then FilterCount += 1

       

        ReDim fCriteria(FilterCount)

        If FilterCount = 0 Then
            fCriteria(0) = Nothing
        Else
            ReDim fCriteria(FilterCount - 1)
            fCriteriaIndex = -1

 

            If rbActive.Checked Then
                fCriteriaIndex += 1
                field = manager.GetCustomEntityFieldDescriptor("ACTIVE_JOB_ORDER", Act.Framework.MutableEntities.FieldNameType.Alias)
                fCriteria(fCriteriaIndex) = New Act.Framework.InFilterCriteria(field, New Byte() {1})
            End If

            If rbInactive.Checked Then
                fCriteriaIndex += 1
                field = manager.GetCustomEntityFieldDescriptor("ACTIVE_JOB_ORDER", Act.Framework.MutableEntities.FieldNameType.Alias)
                fCriteria(fCriteriaIndex) = New Act.Framework.InFilterCriteria(field, New Byte() {0})
            End If

 

            If cboJobCity.Text <> "" Then
                fCriteriaIndex += 1
                field = manager.GetCustomEntityFieldDescriptor("JOB_LOCATION_CITY",  _ 

                    Act.Framework.MutableEntities.FieldNameType.Alias)
                fCriteria(fCriteriaIndex) = New Act.Framework.ComparisonFilterCriteria( _

                   field, _

                   CType(0, Act.Framework.ComparisonFilterCriteria.Operation), _

                   cboJobCity.Text)
            End If

        End If

 

        CustomEntityList = manager.GetCustomSubEntities(ACTApp.ApplicationState.CurrentContact, sCriteria, fCriteria)
       

        If CustomEntityList IsNot Nothing Then CurrentState.JobOrderList = CustomEntityList
        ThisBindingSource.DataSource = CustomEntityList

        EstablishDataBinding()

    End Sub ' FilterList 

 

 

Geoff

Geoff Blood ("The ACT! Customizer" )
The New Hampton Group

ACT Development Partner
Serving the ACC community since 1994
Loyal Listener
Posts: 69
Country: United States

Re: Filter Custom Sub Entity

Thanks Geoff, appreciate the reply. 

 

My issue was specific to filtering by the Custom Entity Record Manager (or Record Creator).  I tried various permutations of "Record_Manager" with code similar to what you have without success.

 

What I eventually found that worked was:

 

Dim field As Act.Framework.CustomEntities.CustomEntityFieldDescriptor

field = manager.GetRecordManagerFieldDescriptor

                   

Dim fCriteria() As Act.Framework.ComparisonFilterCriteria = New Act.Framework.ComparisonFilterCriteria() _
                            {New Act.Framework.ComparisonFilterCriteria(field, Act.Framework.ComparisonFilterCriteria.Operation.Equals, currentUser)}

 

ProjectManagements = manager.GetCustomSubEntities(currentGroup, _
                            New Act.Shared.Collections.SortCriteria() {New Act.Shared.Collections.SortCriteria(manager.GetCustomEntityFieldDescriptor("ActivityDate", Act.Framework.MutableEntities.FieldNameType.Alias), ListSortDirection.Descending)}, fCriteria)

 

Thanks again (VB rocks over C#)

Copper Contributor
Posts: 87
Country: USA

Re: Filter Custom Sub Entity

So its an issue about "getting" the field descriptor for the Record Manager field?  Wonder why that has to be different :-)
Geoff Blood ("The ACT! Customizer" )
The New Hampton Group

ACT Development Partner
Serving the ACC community since 1994