Initializing rows from a multi select custom field

Introduction

This question was raised on Atlassian answers
 

I'm trying to take the options from a multi-select list on an issue and initialize a table grid. I want to put each selected item from the custom field in a different row for the table grid. Is there a way to do this ?


Solution

This can be done by configuring gd.query to retrieve the selected values.
An example query (here specific for mysql) would look like following snippet - with 10070 the customfield id 

gd.query = SELECT cfo.customvalue \ FROM jira.customfieldoption cfo \ inner join customfieldvalue cfv \  on cfo.customfield = cfv.customfield  \ and cfo.id = cast(cfv.STRINGVALUE as decimal) \ where cfo.customfield = 10070 \ and cfv.issue = {issue:id}

 

When hitting the reload button, the query will be run again, replacing all rows which have
not been modified.  This behaviour can be adapted with the  gd.query.keepOnRefresh property