[coldbox:13828] create dynamic table name

You’re going to need to show us more code than that. Is that one line returning the error, or is the error happening later on when you try to use the contents of the rc.req variable?



I am getting

I have the Json that calls the function. Json passing two params tableName and orderBy

When I arrive to the function I have

var rc = event.getCollection(); tblName = rc.tablename; rc.qry= tblName&Gateway.getByAttributes(orderBy = rc.orderby); event.renderData(type="json",data=rc.qry,jsonCase="LOWER",jsonQueryFormat="array",contentType="application/json");

and i get this erro message tblNameGateway is undefined

And then i get this error

This is the issue.

rc.qry= tblName&Gateway.getByAttributes(orderBy = rc.orderby);

I’m not sure what your Gateway is. You are trying to access a variable named “tblName&Gateway”. You probobly want something like

rc.qry = variables[‘tblName’ & variables.Gateway].getByAttributes(orderBy=rc.orderby);

But, that smells off to me also. Really need to know more about your code. What is this Gateway?


The Gateway is the model file. For Example LibraryGateway

And its actually saying variable Gateway is undefined

How are you injecting it? Like this?

component {

property name=“Gateway” inject;

… functions here …

Also, what version of ColdBox?

Yes. For Inject am using

Since it is dynamic am passinf Library for example from the JSOn and then append to the string rc.qry= tblName&Gateway.getByAttributes(orderBy = rc.orderby); .tblname in this case will be Library .