Retrieving values from an Active Choices Reactive Reference Parameter

I am currently using an Active Choices Reactive Reference Parameter (from Active Choices plugin) in a declarative pipeline script. Reacting to a couple of parameters called BRANCH and FULL_BUILD, it loops through the output of a ‘git’ command and creates a HTML checkbox for each line. Below is the ‘parameters’ part of the pipeline:

Understandably, when I query the value of this parameter (MODULE_LIST) in the pipeline steps themselves, I get back something like ‘true,true,false,false,false,false,true’ (depending on which boxes I have checked).

I would like to find a way of knowing the name of the text box (ie. the text next to the checkbox in the UI) as well as it’s value. Is there a way to do this? I tried using JavaScript to update a hidden textbox with a string of what is selected and the reading that as the ‘value’ but I cannot get it working.

Anybody have any suggestions as to the best way of going about this?

1 Like

Hi @Carlos.Cuevas . I don’t use pipelines in my projects, but I do use many, many Active Choice parameters in freestyle projects. Your challenge sounds familiar to me. There are a couple of ways to approach this. First, I also have used Javascript and I usually create a ‘hidden AC reference Html text’ parameter where I collect relevant values from other form parameters as JSON. This allows me to pass a well structured JSON structure to my builds . Alternatively, you can play with the returned values of the check boxes to return a concatenation of the name of the parameter and the true/false value. You need to format this in a way that is easy to parse. I remember doing things like “param1:true;param2:false;param3:true” so I could firsts split on ‘;’ to get the key:value pairs and then splitting each on ‘:’ to get each key and value

1 Like

Thanks for your reply.
I have used your suggestion and created a hidden html input box alongside the checkbox i.e.

html += '<input type="checkbox" name="value" ’ + chk + ‘>’ + it + ‘<input type="hidden" name="value" value="’ + it + ‘">’

As you say, when you then retrieve this parameter, it can simply be split on ,

1 Like