Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Pass report output without HTML

Harley Payne May 28, 2015

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

1 vote
Nelson Carranza
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2015

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

William Crighton _CCC_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2015

nice answer

0 votes
Harley Payne May 29, 2015

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'

Nelson Carranza
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2015

Hi Harley, Do you mind accepting my answer? Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events