Versions Compared

Key

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

...

  1. Log into your Confluence instance.

  2. Navigate to the required page and click .
  3. Insert Wiki Markup macro to write the script.
  4. Write the below script.

    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}


  5. Click on the Save button and the form will be displayed below.
  6. Select the option Add and enter the data. Click on Add button.
  7. Data will be added to the database and displayed as below.
  8. Click Save settings and Save the page. The form is displayed as follows:
    Image Removed
  9. Insert SQL Query macro inside the Run with a user form and parameters macro.
    Image Removed
  10. Edit the SQL Query macro to open the settings pop-up.
  11. Select the required Data source profile from the drop-down.
    Image Removed
  12. Enter the SQL statement based on the Field key mentioned in step 5.
    In the following query, the CAST operator is used to convert the literal strings'2003-01-01' and '2003-12-31' to DATE values.

    Code Block
    languagesql
    Select * from table_name where column_name BETWEEN CAST('$date2' AS DATE) AND CAST('$date1' AS DATE);
    Image Removed
  13. Click Save settings and Save the page.
  14. Enter the date range or select the dates based on the date format mentioned in step 5, and click Show Data on the form.
    Image Removed

The given example displays the following information:
Image Removed
If the user entered a date in an incorrect format (that is, not in the format as specified in the Date format field in step 5), error messages are shown as:
Image Removed

...

  1. Select the option Update and enter the data. Click on Add button.
    Image Added


Info
Test the above the example in a Staging environment before implementing it in production.