That solution seems an excessively complicated way of doing it (I'll suggest this to the original author). It has too much dependency on the user interface.
Here's a simpler approach, using the procedural API to interface with config views. It's not strictly building from a template, but I've given the ability to specify the libList, viewList and stopList via keyword arguments:
procedure(CCFcreateConfigView(lib cell view topView @key
(viewList "spectre cmos_sch cmos.sch schematic veriloga ahdl")
hdb=hdbOpen(lib cell view "w")
unless(hdb error("Could not open %s/%s/%s for write\n" lib cell view))
hdbSetTopCellViewName(hdb lib cell topView)
You can then call:
CCFcreateConfigView("mylib" "mycell" "config" "schematic")
; create using the same options as the "AMS" config template, but with a libList specified as
CCFcreateConfigView("mylib" "mycell" "config_ams" "schematic" ?viewList "spectre spice verilog verilogams behavioral functional systemverilog schematic veriloga vhdl vhdlams wreal" ?stopList "spectre" ?libList "sample")
The assumption in the code is that the lib and cell of the top cell are the same as the lib and cell of the config view; the third arg specifies the config view name and the fourth arg the name of the view for the top cellView.
Hopefully this will do the job for you, and is cleaner.