Forum Discussion

Shivangi's avatar
Shivangi
New Contributor III
11 months ago

How to make use of 'SaveDataTableRows()'

Dear Community, Can anyone please guide me the proper usage of the function  BRApi.Database.SaveDataTableRows(dbConnApp, tableName, columns, hasPrimaryKeyColumns, editedDataRows, throwIfRowForUpd...
  • MarcusH's avatar
    11 months ago

    Here is an example from the MarketPlace app Data Import Schedule Manager (DSM):

    'convert the ado.net data table to an XF data table to access the tables' XF data rows
    Dim xfBalanceDT As New XFDataTable(si, auditTableSchema, Nothing, 1)
    
    Dim editedXFDataRows As New List(Of XFEditedDataRow)
    Dim newXFRow As New XFDataRow()
    newXFRow("TaskID") = randomGuid
    newXFRow("SourceDataOriginType") = SourceDataOriginType
    newXFRow("WorkFlowSteps") = workFlowSteps
    newXFRow("ParallelBatchCount") = ParallelBatch
    newXFRow("LoadMethod") = loadMethod
    newXFRow("WFTimePeriods") = timePeriods
    newXFRow("WFScenarios") = scenarios
    newXFRow("Workflows") = workflows
    newXFRow("TimeStamp") = DateTime.Now
    newXFRow("UserName") = si.UserName
    newXFRow("EmailTemplateID") = emailTemplate
    newXFRow("AddlDataMgmtTask") = addlTask
    newXFRow("AddlTaskBeforeOrAfter") = beforeOrAfter
    
    Dim xfRow As New XFEditedDataRow(DbInsUpdateDelType.Insert, Nothing, newXFRow)
    editedXFDataRows.Add(xfRow)
    'Inserting the row into our table
    Using dbConnInfo As DbConnInfoApp = BRApi.Database.CreateApplicationDbConnInfo(si)
        BRApi.Database.SaveDataTableRows(dbConnInfo, "XFW_DSM_WorkflowImports", xfBalanceDT.Columns, True, editedXFDataRows, False, False, True)
    End Using