FAQ/applying-hidden-filters-programmatically.md
... ...
@@ -47,3 +47,39 @@ public bool FilterCanBeAddedToReport(JoinedTableCollection jts, out Filter newFi
47 47
}
48 48
return toReturn;
49 49
}
50
+```
51
+
52
+##VB.NET Method
53
+
54
+```visualbasic
55
+Public Overrides Sub PreExecuteReportSet(ByVal reportSet As ReportSet)
56
+ If reportSet.IsDashBoard Then
57
+ Dim myReport As Report = reportSet.Reports(0)
58
+ Dim newFilter As Filter = Nothing
59
+ If FilterCanBeAddedToReport(myReport.JoinedTables, newFilter) Then
60
+ myReport.Filters.Add(newFilter)
61
+ End If
62
+ Else
63
+ Dim newFilter As Filter = Nothing
64
+ If (FilterCanBeAddedToReport(reportSet.JoinedTables, newFilter)) Then
65
+ reportSet.Filters.Add(newFilter)
66
+ End If
67
+ End If
68
+End Sub
69
+
70
+Public Function FilterCanBeAddedToReport(jts As JoinedTableCollection, ByRef newFilter As Filter) As Boolean
71
+ Dim toReturn As Boolean = False
72
+ newFilter = Nothing
73
+ For Each jt As JoinedTable In jts
74
+ For Each col As Column In AdHocContext.Driver.DatabaseSchema.Tables(jt.DbTable.FullName).Columns.AllValues
75
+ If col.FullName.ToLower().Contains("Customer_ID".ToLower()) Then
76
+ newFilter = New Filter(col.FullName)
77
+ newFilter.Hidden = True
78
+ newFilter.Value = "BONAP"
79
+ toReturn = True
80
+ End If
81
+ Next
82
+ Next
83
+ Return toReturn
84
+End Function
85
+```
... ...
\ No newline at end of file