OK, here is a totally off the wall question, but we've hit a wall with some functionality that we need to figure out.
We've taken Bob swifts scripting examples and have been able to populate form fields with data derived from preset queries and then we've been able to insert, update, delete or simply view data using the SQL plugins inside of the Run macro. Example:
{groovy:output=wiki} import com.atlassian.renderer.v2.RenderMode def renderMode = RenderMode.suppress(RenderMode.F_FIRST_PARA) def getSql = "select * from table where x = y" def getMacro = '{sql-query:datasource=testdb|table=false} ${getSql} {sql-query}" def get = subRenderer.render(getMacro, context, renderMode) def runMacro = """ {run:id=test|autorun=false|replace=name::Name, type::Type:select::${get}|keepRequestParameters = true} {sql:datasource=testdb|table=false|p1=\$name|p2=\$type} insert into table1 (name, type) values (?, ?) {sql} {run} """ out.println runMacro {groovy}
However, we need to go a little deeper with our functionality. We need to be able to create checks and display some messages based on the query results. for example, if someone completes a form to insert data in a table, we want to be able to run some scripts to check the db first before inserting the data.
Now, we've been able to use a Run macro with Groovy code inside of it to take the values and check the db tables. Example:
{run:id=test|autorun=false|replace=name::Name, type::Type:select::${get}|keepRequestParameters = true} {groovy} def checkSql = "{select * from table where name = '\name' and type = '\$type'}" def checkMacro = "{sql-query:datasource=testdb|table=false} ${checkSql} {sql-query}" def check = subRenderer.render(checkMacro, context, renderMode) if (check == "") { println("This information does not exist.") } else { println(checkMacro) } {groovy} {run}
What we need to be able to do is combine the 2 so that we can use the variables obtained from the main groovy script in the run macro and then use other groovy scripts inside that same run macro. But, I have no idea how to do this or if there are other options out there.
It's like I need to have a combination of the macros:
{groovy} Some scripts {run} {groovy} Some More scripts {groovy} {run} {groovy}
Any help is greatly appreciated!
Thomas,
Did you get anywhere with this?
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.