Community
Showing results for 
Search instead for 
Do you mean 
Reply

Filter Custom Subentity-Error not suppored

Accepted Solution Solved
gkl
Copper Contributor
Posts: 29
Country: Ecuador
Accepted Solution

Filter Custom Subentity-Error not suppored

[ Edited ]

I am trying to filter customentities to make my plugin run faster, as examining one by one takes long. So I tried follow the instructions suggested here : http://community.act.com/t5/forums/postpage/board-id/Pub_Dev but I keep getting "Method not supported" error.

 

Every company in Act has a customsubEntity called Sites

and every Site have many cutomsubentities called Administrators.

 

So i want for a certain company to get all Sites and for every site I need administrators that have custom field "Access_Level"  set to "Full_Access".

So actually I am returning all sites that contains Administators with Full_Access and the Administrators details.

 

In order to do this I was geting all Sites using the Guid of the company and after all Administrators of every site- checking Access_Level of every single Administrator. Pretty slow!

 

So I need to filter the Administrators.

My attemp following the aforementioned post and using c# is this:

 

 

Act.Framework.CustomEntities.CustomEntityDescriptor admindescriptor = ACTFM.CustomEntities.GetEntityDescriptor("Administrators");
                Act.Framework.CustomEntities.CustomSubEntityManager<AdministratorsTable> adminmanager = ACTFM.CustomEntities.GetSubEntityManager<AdministratorsTable>(admindescriptor);
                Act.Framework.CustomEntities.CustomEntityDescriptor sitesdescriptor = ACTFM.CustomEntities.GetEntityDescriptor("Sites");
                Act.Framework.CustomEntities.CustomSubEntityManager<Sites> sitesmanager = ACTFM.CustomEntities.GetSubEntityManager<Sites>(sitesdescriptor);
				
				
            Act.Framework.CustomEntities.CustomEntityFieldDescriptor  field = adminmanager.GetCustomEntityFieldDescriptor("Access_Level", Act.Framework.MutableEntities.FieldNameType.Alias);

                Act.Framework.ComparisonFilterCriteria[] fCriteria = new Act.Framework.ComparisonFilterCriteria[] { new Act.Framework.ComparisonFilterCriteria(field, Act.Framework.ComparisonFilterCriteria.Operation.Equals, "Full_Access")
                    ,new Act.Framework.ComparisonFilterCriteria(field, Act.Framework.ComparisonFilterCriteria.Operation.IsNot, Act.Framework.ComparisonFilterCriteria.NULL_STRING)
                ,new Act.Framework.ComparisonFilterCriteria(field,  Act.Framework.ComparisonFilterCriteria.Operation.IsNot,  String.Empty) 
                };

             var adminlist = sitessmanager.GetCustomSubEntities(site, new Act.Shared.Collections.SortCriteria[] { new Act.Shared.Collections.SortCriteria(adminmanager.GetCustomEntityFieldDescriptor("Access_Level", Act.Framework.MutableEntities.FieldNameType.Alias), ListSortDirection.Descending) }, fCriteria);

 

 When I reach the last line of the above code I get function not supported error!

 


Accepted Solutions
Solution
Accepted by topic author gkl
‎01-16-2016 08:26 AM
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Filter Custom Subentity-Error not suppored

So that said here is the code from Impact Suite which gets the list of child records attached to the current custom table record

 

Public Sub GetChildEntityList()

Try

'-----------------------------------------------

' Check if we have a Current Record on the Binding Source
'-----------------------------------------------
If Me.EntityBindingSource.Current Is Nothing Then
Return
End If

'------------------------------------------------
' Get the Sort Criteria of the GridEx UI control
'------------------------------------------------
Dim SortCriteria As Act.Shared.Collections.SortCriteria() = Durkin.Common.Classes.CustomSubEntity.GetSortCriteriaFromGridEx(Me.GridEX_CustomTables, Me.ChildEntityManager)

 

'------------------------------------------------
' Get the Filter Criteria
'------------------------------------------------
Dim AllCriteriasArray As IFilterCriteria() = New IFilterCriteria(0) {}
AllCriteriasArray(0) = Durkin.Common.Classes.CustomSubEntity.FilterCriteria(Me.ChildEntityManager, "ParentEntityID", 0, Me.EntityBindingSource.Current.ID.ToString())
Me.ChildEntityList = Durkin.Common.Classes.CustomSubEntity.GetEntityList(Me.ChildEntityManager, SortCriteria, AllCriteriasArray)

 

'------------------------------------------------
' Update The BindingSource
'------------------------------------------------
Me.ChildEntityBindingSource = New System.Windows.Forms.BindingSource
Me.ChildEntityBindingSource.DataSource = Me.ChildEntityList

Catch ex As Exception
LogError.Write(ex, "AttachedToCustomTable:GetEntityList")
End Try
End Sub

View solution in original post


All Replies
Copper Contributor
Posts: 7
Country: Greece

Re: Filter Custom Subentity-Error not suppored

Have you defined the custom entities classes as explained in the sdk?

The Administrator is a subentity under subentity if I understand right?

gkl
Copper Contributor
Posts: 29
Country: Ecuador

Re: Filter Custom Subentity-Error not suppored

I have defined the customentities clases to extend Act 

public sealed class AdministratorTable : CustomSubEntity
{

public AdministratorTable(CustomSubEntityInitializationState state)
: base(state)
{
}

}

And yes you got it right, Administrators are subentity under Sites subentity

 

fgh
New Member
Posts: 12
Country: Estonia

Re: Filter Custom Subentity-Error not suppored

[ Edited ]

It can depend on the implementation of the custom entity. Have you followed all the act instruction on how to build custom entities?

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Filter Custom Subentity-Error not suppored

This is sudo code but it may help.

 

 

'------------------------------------------------
' Build the Filter Criteria
'------------------------------------------------
Dim AllCriteriasArray As IFilterCriteria() = New IFilterCriteria(0) {}

 

AllCriteriasArray(0) = MyFilterCriteria(ChildSubEntityManager, FilterFieldName, 0, FilterValue)

 

ChildSubEntityList = ChildSubEntityManager.GetEntityList(Nothing, AllCriteriasArray)

 

 

 

 

Public Shared Function MyFilterCriteria(ByVal EntityManager As CustomSubEntityManager(Of Durkin.Common.Classes.CustomSubEntityDurkin), _
ByVal AliasName As String, _
ByVal CompareOperator As Act.Framework.ComparisonFilterCriteria.Operation, ByVal oValue As Object) As Act.Framework.IFilterCriteria

Try
'----------------------------------------
' Get the Field
'----------------------------------------
Dim CustomFieldDescriptor As CustomEntityFieldDescriptor = Durkin.Common.Classes.CustomSubEntity.GetFieldDescriptorByAlias(AliasName, EntityManager)

'----------------------------------------------------------------------
' Sometime the Word.Addin uses the COlumnName field
' because the AliasName is empty on some of the FieldDescriptors
'----------------------------------------------------------------------
If CustomFieldDescriptor Is Nothing Then
CustomFieldDescriptor = Durkin.Common.Classes.CustomSubEntity.GetFieldDescriptorByANYString(AliasName, EntityManager)
End If

If Not CustomFieldDescriptor Is Nothing Then
'----------------------------------------
' Get the Criteria
'----------------------------------------
Dim CompareCriteria As New Act.Framework.ComparisonFilterCriteria(CustomFieldDescriptor, CompareOperator, oValue)

Return CompareCriteria

Else
Return Nothing
End If


Catch ex As Exception
LogError.Write(ex, "FilterCriteria")
End Try

Return Nothing

End Function

 

Hope this helps

-- Jim Durkin

gkl
Copper Contributor
Posts: 29
Country: Ecuador

Re: Filter Custom Subentity-Error not suppored

[ Edited ]

 

jimdurkin thank you for your reply!

 

You example is really close to what I want to achieve, but I need an alternate for this line

ChildSubEntityList = ChildSubEntityManager.GetEntityList(null, AllCriteriasArray);

 

I dont want to get all Administrators that have "Full Access".

I want all Administrators of a particular Site, that have "Full Access".

 

So I am checking for an alternative of the above code that I can pass a single site entity as parameter.

I have tried the code that I also mentioned in my original post :

 

ChildSubEntityList = ChildSubEntityManager.GetCustomSubEntities(site,null, AllCriteriasArray);

but still get the same error:Non supported.

 

Is there a way to get a list of subentitiies B that are under a subentity A object  with filter criteria  on the subentityB?

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Filter Custom Subentity-Error not suppored

There is no parent/child relation between custom entities in the ACT schema. You thinking top level entities to child entities such as: Contacts/Activities where you can use the top level entity in the SDK like so: getActivities(CurrentContact, filter, criteria).

 

This will not work on child to child.

 

In order to attach an child record to another child record you need to add your own primary Keys (pks) .  In Impact Suite I use fields named 'ParentEntitityID' and 'ParentEntityName'  This allows me to construct the parent child relations between the custom tables.

 

Then in order to query the parent child relations I use the ACT OLEDB reader. I build the SQL select statement from Impact User interface and run the query into my own CustomEntity class named CustomSubEntityDurkin. That's why on a lot of my code example you'll see my own classes

 

'--------------------------------------------------------
' Get the EntityManager for this table
'--------------------------------------------------------

Dim ChildSubEntityManager As CustomEntities.CustomSubEntityManager(Of Durkin.Common.Classes.CustomSubEntityDurkin)

ChildSubEntityManager = Durkin.Common.Classes.CustomSubEntity.GetEntityManager(Me.HostFramework, ChildEntityName)

 

 

'--------------------------------------------------------
' Get a list of records
'--------------------------------------------------------

Dim ChildSubEntityList As Act.Framework.CustomEntities.CustomEntityList(Of Durkin.Common.Classes.CustomSubEntityDurkin)

ChildSubEntityList = Durkin.Common.Classes.CustomSubEntity.GetEntityList(ChildSubEntityManager, CurrentContact, Nothing, Nothing)

 

'--------------------------------------------------------
' Get one record to attach to the currency manager
'--------------------------------------------------------

Dim ChildSubEntityItem As Common.Classes.CustomSubEntityDurkin

ChildSubEntityItem = ChildSubEntityList(0)

 

 

I know its not the answer you are looking for but I thought is may help

 

-- Jim Durkin

Solution
Accepted by topic author gkl
‎01-16-2016 08:26 AM
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Filter Custom Subentity-Error not suppored

So that said here is the code from Impact Suite which gets the list of child records attached to the current custom table record

 

Public Sub GetChildEntityList()

Try

'-----------------------------------------------

' Check if we have a Current Record on the Binding Source
'-----------------------------------------------
If Me.EntityBindingSource.Current Is Nothing Then
Return
End If

'------------------------------------------------
' Get the Sort Criteria of the GridEx UI control
'------------------------------------------------
Dim SortCriteria As Act.Shared.Collections.SortCriteria() = Durkin.Common.Classes.CustomSubEntity.GetSortCriteriaFromGridEx(Me.GridEX_CustomTables, Me.ChildEntityManager)

 

'------------------------------------------------
' Get the Filter Criteria
'------------------------------------------------
Dim AllCriteriasArray As IFilterCriteria() = New IFilterCriteria(0) {}
AllCriteriasArray(0) = Durkin.Common.Classes.CustomSubEntity.FilterCriteria(Me.ChildEntityManager, "ParentEntityID", 0, Me.EntityBindingSource.Current.ID.ToString())
Me.ChildEntityList = Durkin.Common.Classes.CustomSubEntity.GetEntityList(Me.ChildEntityManager, SortCriteria, AllCriteriasArray)

 

'------------------------------------------------
' Update The BindingSource
'------------------------------------------------
Me.ChildEntityBindingSource = New System.Windows.Forms.BindingSource
Me.ChildEntityBindingSource.DataSource = Me.ChildEntityList

Catch ex As Exception
LogError.Write(ex, "AttachedToCustomTable:GetEntityList")
End Try
End Sub

gkl
Copper Contributor
Posts: 29
Country: Ecuador

Re: Filter Custom Subentity-Error not suppored

You last post i what I am looking for. I added 2 filter criteria and the second on is Parent entity, first one is the the Access level filter.Thanks for your contribution.

gkl
Copper Contributor
Posts: 29
Country: Ecuador

Re: Filter Custom Subentity-Error not suppored

[ Edited ]

I would also like to get all administrators with "Full Access" or "Partial Full Access". Is it possible to get an OR operator on the IFilterCriteria array?

Following your method I only get AND between the array elements filter criteria.