Forum Discussion

fc's avatar
fc
Contributor
30 days ago

Extract dbo.vStageSourceAndTargetDataWithAttributes data to csv or txt

Hi everyone,

I need to add a button to a dashboard to allow users to export to csv or txt some data from the staging area, specifically from dbo.vStageSourceAndTargetDataWithAttributes

I tried multiple approaches using a dashboard extender but cannot find the right way to do that.

Has anyone done that before and has any suggestion or best practice to do it (even without using a BR)?

Thank you for the help!

2 Replies

  • db_pdx's avatar
    db_pdx
    Valued Contributor

    Hi fc: if you are already planning to have a dashboard that the end user accesses, you can display the data in a generic grid view component. Users can then Right-Click > Export > To CSV. We put this directly in the import workflow as part of the Validate step. No Business Rules required.

     

    You can also create full 'dashboard button to csv' exports. Our flow is spread across a few BR components (as they are generalized/parameterized), but I would expect it could be all within one Dashboard Extender. Some of the key components include:

    • BRApi.Dashboards.Process.GetAdoDataSetForAdapter(...) - for executing the data adapter that queries the dbo.vStageSourceAndTarget
    • A function/sub for converting from a DataTable to a CSV - we found one from the net. There might be more formal solutions for this now.
    • BRApi.Utilities.SaveFileBytesToUserTempFolder(...) - which saves the output to a temp folder and pops it up on screen for the users like they'd expect with an extract.

     

  • fc's avatar
    fc
    Contributor

    Hi db_pdx​ 

    unfortunately the query I need is not a direct extraction but it includes a calculation and data elaboration, reason why your first solution doesn't work for my case.

    I tried however with your second solution, and I actually managed to export a csv in the file share. However, the export works fine if the number of rows is limited, when the complexity and heaviness of the query increase the client struggles and I need to force close it and open it again to keep working. It seems to be a performance issue more than anything else.
    Let me know if you have any alternative to this approach, but in any case thank you for the help!