---
title: "How to generate choice values using replace and render"
canonical: "https://support.appfire.com/space/SUPPORT/89136586/How%20to%20generate%20choice%20values%20using%20replace%20and%20render"
format: markdown
---
> ❌ **Replace and Render has been retired by Adaptavist**
> ❌ 
> ❌ See [this notice](http://www.adaptavist.com/w/products-plugins/retired-plugins/replace-render/).

> Macro (excerpt)
> 
> Another technique similar to [How to generate choice values using SQL](https://appfire.atlassian.net/wiki/spaces/SUPPORT/pages/89136592)

Here is an example inspired by the folks at iontrading.com! The [Adaptavist Replace and Render](https://marketplace.atlassian.com/plugins/com.adaptavist.confluence.replaceandrender) is very handy for rendering macros for use in other macros.

### Steps

See [How to generate choice values using SQL](https://appfire.atlassian.net/wiki/spaces/SUPPORT/pages/89136592) for a more complete discussion of this topic. 

1. Use a script or SQL to create the selection string needed by the **run** macro
2. Wrap that inside the **replace-item** macro so that it gets evaluated and becomes a replacement value that can be used in the **replace-body **macro
  - Always get this part working first before dynamically putting it in the run macro so it is easier to get syntax exactly right!
3. Construct the **run** macro you want with the selections using the substitution variable

```
{replace-and-render}


{replace-item:%component-selections%}{sql:dataSource=myDS|output=html|heading=false|border=0|table=false}
 select top 785':''',ccc,''':''',ccc,'''' from (
   select distinct component as ccc from releases where 
   date>dateadd([year],-1,GETDATE())
union 
   select distinct component as ccc from installs where  expdate >= getdate() 
)  as c  order by ccc asc
{sql}{replace-item}
{replace-body}

{run:autorun=true|replace=component:sysadmin:Select component:select:%component-selections%}
{run}

{replace-body}

{replace-and-render}
```