Forum Discussion
The below is the code to join application and Framework Tables.
Select Case args.FunctionType
Case Is = DashboardDataSetFunctionType.GetDataSetNames
Dim names As New List(Of String)()
names.Add("MyDataSet")
Return names
Case Is = DashboardDataSetFunctionType.GetDataSet
If args.DataSetName.XFEqualsIgnoreCase("MyDataSet") Then
'Create a Join DT Table
Dim DT_FInal As New DataTable()
'
DT_FInal.Columns.Add("Name")
DT_FInal.Columns.Add("JStatus")
'FrameWork DB
Dim SQL As New Text.StringBuilder()
SQL.AppendLine("Select UniqueID, Name from SecUser")
Dim Fdt As New DataTable
Using DbConnApp As DbConnInfo = BRApi.Database.CreateFrameworkDbConnInfo(si)
Fdt = BRApi.Database.ExecuteSql(DbconnApp, sql.ToString, False)
'Application DB
Dim ASQL As New Text.StringBuilder()
ASQL.AppendLine("Select Case When JournalStatus = 4 Then 'Posted' Else 'Unposted' End AS JStatus,
PostedUserID From JournalHeader")
Dim Adt As New DataTable
Using ADbConnApp As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
Adt = BRApi.Database.ExecuteSql(ADbConnApp, ASQL.ToString, False)
'LinQ Query
Dim aa
Dim Query = From fuser In Fdt.AsEnumerable _
Join auser In Adt.AsEnumerable _
On fuser.Field(Of system.Guid)("UniqueID") Equals auser.Field(Of system.Guid)("PostedUserID") _
Select New With {Key .Name = fuser.Field(Of String)("Name"), _
Key .JStatus = auser.Field(Of String)("JStatus")}
For Each aa In Query
DT_FInal.rows.Add(aa.Name, aa.JStatus)
Next
Return DT_FInal
End Using
End Using
End If
End Select
- adykes3 years agoNew Contributor III
Hi Krishna, thanks for your response, it is very helpful. I am new to Dashboard Data Set BRs and am wondering how would you go about calling this function in a Data Adapter? Thanks
- adykes3 years agoNew Contributor III
Sorry, I have another question: In your code, you refer to "JStatus", but I am trying to connect the dots back to the database tables and JStatus does not seem to be a column in the Journal Header application table. FYI, I am trying to use this code to join the SecUser table with the DataEntryAuditSource application table, so I am tweaking the code slightly to fit my purposes, hence the question 🙂
- Krishna3 years agoValued Contributor
The Jstatus see below which is the Journalstatus column in the DB Tables JournalHeader and I am loading into the Datable of JSTATUS. Make Sense ?
ASQL.AppendLine("Select Case When JournalStatus = 4 Then 'Posted' Else 'Unposted' End AS JStatus,
PostedUserID From JournalHeader")- adykes3 years agoNew Contributor III
I understand, thank you!