Here's hoping that someone here can help out with this.
I am using script runner to do a query of an external database. Here are my exact requirements. On an existing JIRA issue, use two custom fields, both of type text. Field names are: Customer and PIN. Then query an external database, and return the result to another variable. There is a bit more than that, but for the purposes of this question this is good enough.
Using groovy and an example provided by Jamie, I am able to do a query on the other sql database. I can get the information that I need, if I hard code (statically define) in the two custom fields in the groovy script. That is, Customer = "Acme", and PIN = "1234". So I know that my connection and syntax are correct. What I can't figure out is how do I get and use the contents of my two custom fields, and pass them to the query instead of using a static defined variable.
Ultimately I am looking to have a workflow transition that the user can click on. The transition would execute the groovy script, which would then go out to the other database and do the query to verify the two fields in question and return to a third field a "Verified", or "Not Verified". Or behaviour similar to that.
Has anyone tried to do this before, or have any other suggestions on how I could accomplish this? I have plenty of examples of how to do a general query and update the custom field in JIRA, just not of how to 'use' the contents of an existing field. I'm sure that the information exists somewhere, I just haven't been able to find it so far.