Automatic addition of FX Rate Types
Hi All,
I am trying to automate addition of FX Rate Types on a button click with some logic.
Inserting values into FxRateType and AuditFxRateType using the below code snippet
------------------------------------
Public Sub AddCurrentFXRate(ByVal si As SessionInfo, ByVal api As Object, ByVal sCurrentOpsName As String, ByVal dt As DataTable)
Dim dbConnApp As DBConnInfo = BRAPi.Database.CreateApplicationDbConnInfo(si)
Try
Dim sSQL As New Text.StringBuilder
Dim sFXRateTypeGuid As String = Guid.NewGuid.ToString
sSQL.AppendLine("INSERT INTO FxRateType
(UniqueID, Name, Description,
AccessGroupUniqueID, MaintenanceGroupUniqueID, XmlData)
VALUES ('" & sFXRateTypeGuid & "', '" & sCurrentOpsName & "', '" & sCurrentOpsName & "',
'" & dt.Rows(0)("AccessGroupUniqueID").ToString & "', '" & dt.Rows(0)("MaintenanceGroupUniqueID").ToString & "', ' ')")
sSQL.AppendLine("INSERT INTO AuditFxRateType
(AuditGuid, AuditSeqId, AuditUser,
AuditTime, AuditInsUpdateDel,
UniqueID, Name, Description,
AccessGroupUniqueID, MaintenanceGroupUniqueID, XmlData)
VALUES ('" & Guid.NewGuid.ToString & "', '1', '" & BRApi.Security.Authorization.GetUser(si, si.AuthToken.UserName).User.Name & "',
'" & DateTime.Now & "', '0',
'" & sFXRateTypeGuid & "', '" & sCurrentOpsName & "', '" & sCurrentOpsName & "',
'" & dt.Rows(0)("AccessGroupUniqueID").ToString & "', '" & dt.Rows(0)("MaintenanceGroupUniqueID").ToString & "', ' ')")
Using dbConnApp
dbConnApp.BeginTrans()
BRAPi.Database.ExecuteSql(dbConnApp, sSQL.tostring, False)
dbConnApp.CommitTrans()
End Using
Catch ex As Exception
dbConnApp.Dispose()
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Sub
------------------------------------
The values get added into the tables fine, but the newly added rate type does not show in FX Rates interface even after refreshing the application. Would someone please guide what I am missing here?