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=======
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("<[^>]*>", "").trim();
Regards
Nelson
nice answer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Harley, Do you mind accepting my answer? Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.