Pass report output without HTML

Hello

 

I am trying to use a Confluence to lookup a value from a Scaffolding table, and then pass this value into an SQL macro.    I was planning on using groovy for this and it is working fine, but the value that gets passed has HTML tags around it (even though I set the text field in Scaffolding to be plain text).

 

How can I configure this to pass the value without the <p></p>?    So using the script shown below I am getting a value of    <p>12345</p> passed as ${mapobjidset} when what I need is just 12345.

 

My groovy text is below:

=========

import com.atlassian.renderer.v2.RenderMode
def renderMode = RenderMode.suppress(RenderMode.F_FIRST_PARA)

// macro to pull the correct mapobjid value
def mapobjidMacro = """
{report-block}
   {local-reporter:key=data:TestTable}
      {text-filter:
          key=data:WorkflowIDField
        | value=PAF
      }
   {local-reporter}
   {report-body}
      {report-info:key=data:MapObjIDSetField}
   {report-body}
{report-block}
"""
 
def mapobjidset = subRenderer.render(mapobjidMacro, context, renderMode)

// now run the SQL using the chosen mapobjid
def SQLMacro = """
{sql-query: 
    dataSource=DS
  | noDataMessage=N/A}
SELECT 
   Map_MapID,
   Map_Title,
   Map_MapObjID
FROM
   DS.WMap
WHERE
   Map_MapObjID IN (${mapobjidset})
{sql-query}
""" 
 
out.println SQLMacro

=======

2 answers

Hi Harley,

 

I would try using the injected functionality from reporting. This will work if you are expecting one single value. I do not see that your groovy handle multiple values neither , but im not familiar with groovy so i cant really tell. 

Let say report returns 3 ids, so I think: mapobjidMacro will be = "id1 id2 id3"  so sql query will fail since it is expecting  "id1", "id2", "id3"

 

https://docs.servicerocket.com/display/REP/Injecting+Parameters+with+Parameter+Injections

 

{report-block}
   {local-reporter:key=data:TestTable}
      {text-filter:
          key=data:WorkflowIDField
        | value=PAF
      }
   {local-reporter}
   {report-body:injected=true}
      
	  
	  {sql-query: 
    dataSource=DS
  | noDataMessage=N/A}
SELECT 
   Map_MapID,
   Map_Title,
   Map_MapObjID
FROM
   DS.WMap
WHERE
   Map_MapObjID IN ('%data:MapObjIDSetField%')
{sql-query}
   {report-body}
{report-block}

 

If you are expecting multiple values , since you are using IN , Can you do something like this:

mapobjidMacro  = mapobjidMacro.replaceAll("&lt;[^&gt;]*&gt;", "").trim();

 

Regards

Nelson

That worked well thanks.    Simpler than the groovy approach.    I have control over the scaffolding text so I can just format it properly to pipe in....   ie for multiple - '1234', '5678'

Hi Harley, Do you mind accepting my answer? Thanks

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

98 views 1 14
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you