BPM, Workflow, and Case

BPM, Workflow, and Case

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
Expand all | Collapse all

Creating Table with Dynamic Columns from Service Flow

  • 1.  Creating Table with Dynamic Columns from Service Flow

    Posted Wed February 26, 2025 09:57 AM

    Hi all,

    I am currently working on a project, where a user needs to be able to select one table from a database and then display it in the Coach View. The user then needs to be able to edit the values and add new rows to the table in BAW. These changes are sent back to the database.

    One way to solve this would be to make a separate service flow, BO and table view for each corresponding table in the database. However there is a large number of tables in the database and this approach lacks flexibility as new tables might be added into the database. 

    My question is would it be possible to have only one service flow and table view that would dynamically adjust depending on what table from the database is selected.

    Note: (The tables in the database have different numbers of columns)



    ------------------------------
    Ismael Ragab
    ------------------------------


  • 2.  RE: Creating Table with Dynamic Columns from Service Flow

    Posted Mon March 03, 2025 10:05 PM

    Hi Ismael,

    The solution will depend on your db engine you are targeting so considering MSSQL

    You need to retrieve all the table on your database from different schemas as per below

    01) Create service flow to load tables on your database

    SELECT TABLE_NAME
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_TYPE = 'BASE TABLE'
    AND TABLE_CATALOG = 'YourDatabaseName';
    

    02) load them in single select 

    03) Upon selecting table from single select you will load these data in 

    SELECT * FROM [YourSchemaName].[YourTableName];

    04) If needed you can load Table structure as below

    SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'YourTableName';

    05) The trick here in loaded dynamic table which can be applied using custom HTML to generate table with add button to insert new record and the insert/update logic can be tricky based on constraints & relation in your database.

    06) After click 'Add' Button mentioned above you can pass json string as input to Service flow with target database name and generate the Insert Statement & Execute.



    ------------------------------
    Mohammed Shaker
    IBM BPM Consaultant
    Valleysoft
    Nasr City
    01007073310
    ------------------------------