RE: [coldbox:13833] create dynamic table name

> And its actually saying variable Gateway is undefined

Earlier in the thread you said that “tblNameGateway” was undefined. Which is it?

Let me take a stab at what you are doing. Do you have a series of tables such as Foo, Bar, and Fubar and a series of gateway CFCs called FooGateway, BarGateway, and FubarGateway?

And then you’re trying to invoke the correct gateway CFC dynamically at runtime based on the tblName variable that’s passed in?

If so, I think you need to take an approach like Aaron showed, where you first concatenate the necessary strings to build the name of your CFC.

local.gatewayName = rc.tblName & ‘gateway’;

Then you get it out of the variables scope with array notation.

local.oGateway = variables[local.gatewayName];

Then, call whatever methods on it you want.


I would recommend coding it in that order to ensure each part works. Then you can combine the working product to condense the number of lines of code.

variables[rc.tblName & 'gateway’].getByAttributes();

Also, how are all the gateways being defined in your code? Are they defined, and in what scope??

If this isn’t what you are doing, please provide more information. You haven’t given us much to work on.