Community
Showing results for 
Search instead for 
Do you mean 
Reply

Filter histories by HistoryTypeSuperGroupId

New Member
Posts: 14
Country: United_Kingdom

Filter histories by HistoryTypeSuperGroupId

HI, I am currently retriving all histories for a selected company in vb.net. What I want to do is to exclude HISTORYTYPESUPERGROUPID = 5 and am completly lost as I cant find a history filter type or a history lookup.

 

Bellow is the code I have used 

 

        Dim oHistory As Act.Framework.Histories.History
        Dim oHistories As Act.Framework.Histories.HistoryList
        Dim oDate As HistoryFieldDescriptor

        Dim cfd As CompanyFieldDescriptor
        Dim oCompanies As Act.Framework.Companies.CompanyList
        Dim oCompany As Company

        cfd = oActFwk.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.NAME")
        Dim oSortC() As SortCriteria = {New SortCriteria(cfd, ListSortDirection.Ascending)}

        oCompanies = oActFwk.Companies.GetCompanies(oSortC)
        oCompany = oCompanies.Item(recordNo)

        Dim oSortH As HistorySortCriteria() = {New HistorySortCriteria(oDate, ListSortDirection.Ascending)}

        oHistories = oActFwk.Histories.GetHistories(oSortH, oCompany, Nothing, Nothing, False)

        Dim histories(oHistories.Count, 2) As String
        Dim i As Integer
        For i = 0 To oHistories.Count - 1
            oHistory = oHistories(i)
            histories(i, 0) = Left(oHistory.CreateDate, 10)
            histories(i, 1) = oHistory.Regarding
            histories(i, 2) = oHistory.ManageUserName
        Next i

 

 

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Filter histories by HistoryTypeSuperGroupId

Hi there,

 

Actually filtering Histories is not that intuitive initially! You create the filter by creating an object of the IFILTERCRITERIA interface. In creating that you also use an object that implements the IFilterCritieria interface such as the DateFilterCriteria.

 

Once you have those you can then use the GetHistories overload that takes the IFilterCriteria implementing object.

 

Its ugly and I personally think breaks the Object model but that's the way it is and I suspect that's the way it will always remain till unless there is a decision to re-write from the ground up!

 

 

Hopefully that all makes some kinf of sense to you!

HTH

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
New Member
Posts: 14
Country: United_Kingdom

Re: Filter histories by HistoryTypeSuperGroupId

I did look at using IFILTERCRITERIA but I had no idea what object to use as I couldn't filter for history type and couldn't find one that looked close.
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Filter histories by HistoryTypeSuperGroupId

ok sorry I didn't pay enough attention! 

 

What you could use is the InFilterCriteria to creat the IFilterCriteria array. For the InFilterCriteria object you can use the HistoryFieldDescriptor object that defines the HistoryType field which is a simple character field i.e. string.

 

I've unfortunately got to go to a client's site now so hopefully if I haven't been able to help someone else might be better able!

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
New Member
Posts: 14
Country: United_Kingdom

Re: Filter histories by HistoryTypeSuperGroupId

[ Edited ]

Thanks that has definatly put me on the right track. I have got it working with "HISTORYTYPEID" but if I use "HISTORYTYPEGROUPID" or "HISTORYTYPESUPERGROUPID" I get the following error "Requested value 'HISTORYTYPEGROUPID' was not found"

 

 I am happy to use  HISTORYTYPEID but if any one knows how to use any of the other two I would appreciate it as I would prefere to enter groups into the filter rather than specfic types.

 

hfd = oActFwk.Histories.GetFieldDescriptor("HISTORYTYPEID")
historyGroups = {0, 1, 2, 16}
Dim oFilter As Act.Framework.IFilterCriteria() = {New InFilterCriteria(hfd, historyGroups)}

 

New Member
Posts: 14
Country: United_Kingdom

Re: Filter histories by HistoryTypeSuperGroupId

I have managed to achieved what I was aiming for by limiting to user recordable in GetHistoryTypes

hfd = oActFwk.Histories.GetFieldDescriptor("HISTORYTYPEID")
Dim arrayOfHistTypes As HistoryType() = oActFwk.Histories.GetHistoryTypes(True, True, True)
Dim k As Integer
Dim historyGroups(UBound(arrayOfHistTypes)) As Integer
For Each hT As HistoryType In arrayOfHistTypes
        historyGroups(k) = hT.HistoryTypeId
        k = k + 1
Next
Dim oFilter As Act.Framework.IFilterCriteria() = {New InFilterCriteria(hfd, historyGroups)}