Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article explains how to create a form to insert and update the data into the database.

Before we proceed with the instructions, below are the prerequisite:

  1. These apps need to be installed on your Confluence instance:
    1. Run Self-Service Reports
    2. SQL for Confluence (Pro Edition)
  2. Follow this link to configure the data source profile for SQL for the Confluence app.

...

  1. Log into Confluence.

  2. Navigate to the existing page and click  to edit the page or create a new page.
  3. Insert Wiki Markup macro and paste the below content.

    Code Block
    languagegroovy
    themeMidnight
    {wiki}
    {run:titleRun=DATA Display|anchor=result}
    
            {run}
    
              {run:id=update|replace=choice:Add::radio::Add::Update,id:1:Id (for update):integer-select:1:1000,type:dog:Select DB:select::MYSQL_new user:MYSQL_new          user:Mysql_confluence:Mysql_confluence,hand1:default:operational_hand_off_status:text,hand2:default:project_status:text,hand3:default:Resource Type:text|titleRun=Add|autoRun=true|anchor=result|focus=choice}
               {anchor:result}
    
                {hide:showIf=Add:$choice}
    
                {sql:dataSource=Mysql_confluence|contentPropertyPrefix=sql.}
    
                INSERT INTO report (Project_status,Resource_type,operational_hand_off_status)VALUES('$hand2','$hand3','$hand1');
    
                {sql}
    
                *Row Updated*
    
                {hide}
    
                {hide:hideIf=Add:$choice}
                {sql:dataSource=Mysql_confluence|contentPropertyPrefix=sql.}
                UPDATE report set Project_status = '$hand2', Resource_type ='$hand3',operational_hand_off_status = '$hand1' where report_id = $id
                {sql}
                {hide}
            
    {run}
            
      {run-now}
                {hide:showIf=1:%property_sql.update_count%}
                *Row Added*
                {hide}
    
      {run-now}
                ----
                h3. Results
                {sql-query:dataSource=MYSQL_new user}
                select report_id,Project_status,Resource_type,operational_hand_off_status from report
                {sql-query}
           
      
    {wiki}


  4. Click Insert
  5. Click Save. The macro is displayed as mentioned below:
    Image RemovedImage Added
  6. Select the choice: Add to insert a new record and Update to edit the record.
  7. Enter data in the required fields and click Add to save the data into the database.
    Image RemovedImage Added
  8. Data is added/updated to the database and displayed as shown below:
    Image RemovedImage Added


Info
  • Test the above the example on the non-production environment before implementing it on production.
  • Change the field value parameters based on your data.

...