How to generate choice values using replace and render

Replace and Render has been retired by Adaptavist

See this notice. 

Another technique similar to How to generate choice values using SQL

Here is an example inspired by the folks at iontrading.com! The Adaptavist Replace and Render is very handy for rendering macros for use in other macros.

Steps

See How to generate choice values using SQL 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}

 

Â