Using Parameters in a CC4 connection

tshirley 29 Jan, 2015
Hi there,

I want to call a CC4 connection from a CF4 Form which passes a parameter to the Connection.

For example I can use a Redirect URL and include a parameter "Mbr_Nbr" in the URL that calls the CC4 Connection. Then I want only the records that match the value of Mbr_Nbr to be listed.

How do I make the connection filter on the value of this parameter? What syntax can I use in the Where SQL box that will do this?

It seems like something that should be basic functionality (as it is in CF4) so I expect it is simple to do.

Cheers

Tim
GreyHead 29 Jan, 2015
Hi Tim,

I suspect that there is a built in way to do it but I don't know what that is from memory. Try this in the WHERE box
<?php
$member = JRequest::getInt('Mbr_Nbr', 0, 'get');
if ( $member > 0 ) {
  return " `Mbr_Nbr` = $member ";
}
?>
This assumes that your member number is an integer, it needs tweaking a bit for a string.

Bob
tshirley 29 Jan, 2015
I suppose that if the parameter is a string it would be something like:

$member = JRequest::getString('Mbr_Nbr', '','get',$mask=0);

I have a few of these to do, some string and some integer, so I need a general solution🙂

And the parameter Mbr_Nbr must be put into the Params Fields section of the General Tab.

I'll do some more testing.
tshirley 30 Jan, 2015
Hi Bob,

OK, results of testing using the CC Debug display are this:

If I put a simple SQL clause like Member = 'M1000' in the WHERE box, it works, just as it does in the CF4 Data Loader.

However anything else does not work. The code above, and every variation of it I try, adds nothing in the WHERE clause of the query at all.

In CF of course I have access to the form->data array and to the incoming parameters, and so I can control the Data Loader to do this sort of thing. I had hoped this would be easy in CC so that I can use the other features of CC in my site. However, if that isn't possible I can still use the CF to do what I need.

Cheers

Tim
This topic is locked and no more replies can be posted.