Community
Showing results for 
Search instead for 
Do you mean 
Reply

Dashboard question - How to get parent entity information on a subentity filter

Copper Contributor
Posts: 28
Country: Canada

Dashboard question - How to get parent entity information on a subentity filter

I have developed a plug-in with a custom subentity (Parent entity is Companies) and now I need to create a dashboard plugin to filter some of that data.  I can pull the data from the subentity no problem.  However the data makes little to no sense without a company name attached and I'm running into issues pulling sub entity fields with native data fields.  Currently my code looks like this:

 

Dim FilteredList As Act.Framework.CustomEntities.CustomEntityList(Of MyClass)

Dim BS as New BindingSource


FilteredList.FieldDescriptors.Add(ActiveFramework.Companies.GetCompanyFieldDescriptor("Company.Company", False)) ' Problem Line

FilteredList.FieldDescriptors.Add(CustomEntityManager.GetCustomEntityFieldDescriptor("FIELD1", Act.Framework.MutableEntities.FieldNameType.Alias))
FilteredList.FieldDescriptors.Add(CustomEntityManager.GetCustomEntityFieldDescriptor("FIELD2", Act.Framework.MutableEntities.FieldNameType.Alias))
FilteredList.FieldDescriptors.Add(CustomEntityManager.GetCustomEntityFieldDescriptor("FIELD3", Act.Framework.MutableEntities.FieldNameType.Alias))


BS.DataSource = FilteredList

DataGridControl.DataSource = BS


 

Commenting out the problem line gives me all the data without any useful context.  Leaving the line in, the code runs but throws an error when assigning the data to the data grid control.  It's a data error so the try catch loop completely fails. 

 

The error says that it can't assign type Act.Framework.Companies.Company  from MyProject.MyProject.MyClass Parameter name: item at Act.Framework.MutableEntities.MutableEntityFieildDescriptor.GetMutableEntity(Object item) at Act.Framework.MutableEntities.MutableEntityFieldDescriptor.GetValue(Object item) at System.Windows.Forms.DataGridView..DataGridViewDataConnection.GetValue(Int32 boundColumnIndex, Int32 columnIndex, Int32rowIndex)

 

The class in question in its entirety:

 

Public Class MyClass
Inherits CustomSubEntity
' Required constructor
Public Sub New(ByVal state As CustomSubEntityInitializationState)
MyBase.New(state)
End Sub
End Class

 

I'm sure I'm missing something obvious, but my eyes are crossing at this point.

gkl
Copper Contributor
Posts: 29
Country: Ecuador

Re: Dashboard question - How to get parent entity information on a subentity filter

Any luck with that question kwill?I am also trying to get a a custom table, created from a pluging that is associated with the company table. Every entity of my custom table can be associated with many companies and every company can be associated with many custom entities. Is there a way to get for a give company all associated custom table entities?

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Dashboard question - How to get parent entity information on a subentity filter

 

' Get the company list from the SubEntity Record

Dim CompanyList As Act.Framework.Companies.CompanyList = SubEntityItem.GetCompanies(Nothing)

 

' Set 

SubEntityItem.SetCompanies(CompanyList)

 

Hope this helps

gkl
Copper Contributor
Posts: 29
Country: Ecuador

Re: Dashboard question - How to get parent entity information on a subentity filter

This is helpful!But is it possible to go the other way round. The problem is I have the companyid available and I want to find for this company the associated custom table objects. The way you suggest I get all custom tables objects and every time I have the company-companies associated with that and check if they have id same as the companyid, I have available. It is taking too long as it iterates through all record of custom table.

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Dashboard question - How to get parent entity information on a subentity filter

 

 

Dim cCompanyList As Act.Framework.Companies.CompanyList = HostFramework.Companies.GetCompaniesByID(Nothing, New Guid() {HostApplication.ApplicationState.CurrentContact.CompanyID})

 

Me.EntityList = Me.EntityManager.GetCustomSubEntities(cCompanyList(0), Me.EntitySortCriteria, Me.FilterCriteriaACT)

 

Does this help?