How to access output of query in the controller

36 views
Skip to first unread message

fuseBoxer

unread,
May 9, 2011, 4:57:38 PM5/9/11
to framework-one
In my controller I have:
variables.fw.service( "user.getuserinfo", "getUserInfo" );

This returns a result set in "getUserInfo" and <cfdump
var="#getUserInfo#" /> confirms this -- ie I see the result of the
query.

This statement on the next line in the controller:
if(IsDefined("rc.getUserInfo.RecordCount") AND
rc.getUserInfo.RecordCount)
gives the error: "recordcount" doesn't exist.

Can I refer to the recordcount (or columns from the returned query) in
the controller from which it is called?

Thanks for any help. I'm new to F/W1.

Eapen

unread,
May 9, 2011, 5:19:53 PM5/9/11
to framew...@googlegroups.com
The results of the (implicit) service call made in "startItem" function in the controller is only available in the "endItem" function in the controller. The service call is not run immediately but is queued for execution after the "startItem" & "item" functions have been called in the controller. 

If you want it available immediately, you need to explicitly make the service call. There have been several discussions about this in the Groups so you may want to search the archive as well.

fuseBoxer

unread,
May 11, 2011, 9:19:39 AM5/11/11
to framework-one
I actually call the query in the startDefault group explicitly like
this:
variables.fw.service( "applicant.getuserinfo", "getUserInfo" );

Then in the same function I tried accessing rc.getUserInfo.RecordCount
but it said it did not exist.

I can, however, confirm it is there using this:
if(IsDefined("rc.getUserInfo") AND IsStruct(rc.getUserInfo))

And I can refer to column names like this: rc.getUserInfo.first_name.

So is there a way to get the recordcount when the query is in the rc
scope?

Thanks for your help on this.

fuseBoxer

unread,
May 11, 2011, 9:26:41 AM5/11/11
to framework-one
By explicit you mean a call to a bean factory? That may be the issue.
I thought THIS was an explicit call:

Eapen

unread,
May 12, 2011, 12:16:54 AM5/12/11
to framew...@googlegroups.com
No, by explicit call I meant, calling it as <cfset applicant.getUserInfo = createObject("component", "explicitServices.user").getUserInfo()>.

If you do that, the results will be available immediately. If you are depending on FW/1 to make the service call (implicit), then the recordcount will only be available in the endDefault() function in the controller. 

Reply all
Reply to author
Forward
0 new messages