Need help adding an Access Profile select list to an iApp template

As a test I’ve added an Access Profile text box to my template to see if attaching an Access Profile to an iApp generated virtual server would work similar to the way external iRules can be associated (without having to break Strict Updates). All seems to have gone well. Here’s the relevant excerpts…

optional ( intro.apm_provisioned == "provisioned" ) {
    section apm {
        string access_profile display "xlarge" default "None"
        optional ( access_profile != "None" ) {
            choice sso display "large" default "No" {
                "No" => "No",
                "Yes"    => "/Common/websso"
            }
        }
    }
}
apm "Access Policy"
apm.access_profile "Select Access Profile "
apm.sso "Single Sign-On"

So now my question is, what black magic do I use to dynamotronically list all the possible Access Profiles within a select list?

Hi Sam, the f5.microsoft_exchange_2010_2013_cas.v1.5.1 template (available on downloads.f5.com) includes this functionality. The choice looks like this:

choice apm_profile display "xxlarge" default "/create_new" tcl {
                set ::choices "Create a new Access Profile\t/create_new\n[tmsh::run_proc f5.iapp.1.3.0.cli:iapp_get_items -nocomplain apm profile access]"
                return [tmsh::run_proc f5.iapp.1.3.0.cli:iapp_safe_display ::choices]
            }

Mike’s answer is correct, but here is a way to do it without using the cli script:

choice y tcl { 
    foreach obj [tmsh::get_config apm profile access] {
        append rval "[tmsh::get_name $obj]\n"
    }
    return $rval
}

Refer to https://devcentral.f5.com/wiki/TMSH.Commands.ashx