0

Situation:

context contains such fields as testExecutionKey1, testExecutionKey2 .. testExecutionKey10

I want to check them for null, but do it the nice way - in for loop

I need to access $context.testExecutionKey1..10 inside the loop, where number is $i

{for $i in range(1, 11)}
    {if {$context.testExecutionKey}{$i}}
        <div class="aui-message aui-message-info">
            <p>A Test instance execution is already linked to this issue: <a href="$baseURL/browse/$context.testExecutionKey${$i}" target="_blank">${context.testExecutionKey{$i}}</a>.</p>
        </div>
        <input type="hidden" name="skip-test-execution-${$i}" value="true">
    {/if}
{/for}

Problem:

PHP has got variable variables feature, but I could no similar find for closure templates in docs.

Chad Killingsworth
  • 14,360
  • 2
  • 34
  • 57
A. Knorre
  • 134
  • 1
  • 6
  • 1
    `testExecutionKey1`...`testExecutionKey10` should be an *array*. – T.J. Crowder Oct 17 '17 at 16:49
  • @T.J. Crowder Yep, sorry, php tag deleted. It can not be array as Jira's FormParameters returns only String value by a String key, so no other choice here, do you have any ideas? – A. Knorre Oct 17 '17 at 16:52
  • 1
    Is this even a JavaScript question? Sounds like it's just the templating tech. If it were JavaScript, the answer would be `$context['testExecutionKey' + $i]` ([see here](https://stackoverflow.com/questions/4244896/dynamically-access-object-property-using-variable)), but... – T.J. Crowder Oct 17 '17 at 16:58

1 Answers1

0

Reimplementing jira context the proper way is the way to go

A. Knorre
  • 134
  • 1
  • 6
  • 1
    Could you remove the (Solved) from the title again? It's not really needed and if the site needed it they'd add it automatically. – LW001 Oct 17 '17 at 17:17