Insert cf_id into the response email

Shows some Tutorials

Insert cf_id into the response email

Postby websavages1 on Wed Jul 25, 2007 8:33 am

Greetings,

I have created a form and the results are email to the relevant party. However I would like to add the value for cf_id in the email.

Any ideas?

Cheers ws
websavages1
Fresh Boarder
 
Posts: 9
Joined: Wed Jul 25, 2007 1:30 am

Re:Insert cf_id into the response email

Postby GreyHead on Wed Jul 25, 2007 1:52 pm

Hi websavages1,

I'm assuming that cf_id here is the ChronoForms form id? If that's right then you can include a hidden field in your form like this:
Code: Select all
<input type='hidden' name='cf_id' value='<?php echo $rows[0]->id ?>' />
and that will give you the form id in the form variable 'cf_id' that you can include in your e-mail like any other variable.

Does this help?

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3251
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Insert cf_id into the response email

Postby websavages1 on Wed Jul 25, 2007 2:26 pm

Unfortunately not.

Once the user has submitted the form I would like to include the newly created cf_id in the email which is sent.

Doing it via your method means I can only access the data which has already been created.

Cheers ws
websavages1
Fresh Boarder
 
Posts: 9
Joined: Wed Jul 25, 2007 1:30 am

Re:Insert cf_id into the response email

Postby GreyHead on Wed Jul 25, 2007 3:07 pm

Hi websavages,

Sorry, I misunderstood the id you were looking for. At present the database entry is created after the e-mail is sent so you don't know what the cf_id will be (it's autogenerated when the database entry is written).

I'd need to go and check my MySQL manual but I think that there is an SQL command that will generate the 'next ID'. Perhaps putting that in the 'OnSubmit code- before email' would do the trick.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3251
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Insert cf_id into the response email

Postby websavages1 on Wed Jul 25, 2007 6:11 pm

So instead of the auto-generate section creating the database entry, the 'OnSubmit - before email' section generates the database entry. That's a possibility, however, how do I (once I have got the newly created cf_id value) get the value for cf_id into the email?

Cheers ws
websavages1
Fresh Boarder
 
Posts: 9
Joined: Wed Jul 25, 2007 1:30 am

Re:Insert cf_id into the response email

Postby admin on Wed Jul 25, 2007 7:44 pm

Hi Ws,

Lets try this trick, at the onsubmit AFTER email box plz write :

Code: Select all
echo $html_message;


what do you get after submitting the form now ?<br><br>Post edited by: admin, at: 2007/07/25 15:46
ChronoForms Developer Thanks for using ChronoForms.
If you have any problems with ChronoForms please tell us.
If you like ChronoForms please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
User avatar
admin
Platinum Boarder
 
Posts: 2107
Joined: Mon Aug 14, 2006 5:29 am

Re:Insert cf_id into the response email

Postby GreyHead on Wed Jul 25, 2007 10:29 pm

Hi ws,

Try putting this code in the 'On Submit code - before sending email' field (remember to replace 'jos_chronoforms_nn' with the name of your particular form table):
Code: Select all
<?
$cf_id = 0;
$tablename = "jos_chronoforms_nn";
$query = "SHOW TABLE STATUS LIKE '$tablename'";
$result = mysql_query($query) or die ( "Query failed: " . mysql_error() . "
" . $query );
$row = mysql_fetch_assoc($result);
$cf_id = $row['Auto_increment'];
?>
The you can use
Code: Select all
<?php echo $cf_id ?>
in your email template.

Note that this bypasses the Joomla database handler and requires that you find the mysql tablename e.g. jos_chronoforms_nn' instead of the Joomla version '#__chronoforms_nn'.

Bob<br><br>Post edited by: GreyHead, at: 2007/07/26 10:04
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3251
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Insert cf_id into the response email

Postby websavages1 on Thu Jul 26, 2007 5:47 am

Oops can't delete a reply. I didn't read the reply on the second page. I'll give it a go today (overnight your time)

Cheers ws<br><br>Post edited by: websavages1, at: 2007/07/26 02:46
websavages1
Fresh Boarder
 
Posts: 9
Joined: Wed Jul 25, 2007 1:30 am

Re:Insert cf_id into the response email

Postby websavages1 on Thu Jul 26, 2007 4:30 pm

No joy, the email source contains the php code un parsed.

Cheers ws
websavages1
Fresh Boarder
 
Posts: 9
Joined: Wed Jul 25, 2007 1:30 am

Re:Insert cf_id into the response email

Postby GreyHead on Thu Jul 26, 2007 5:25 pm

Hi ws,

I'm not sure if you're replying to my post or Max's. I'm hoping that it's Max's ;) as mine *should* give you what you want.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3251
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Insert cf_id into the response email

Postby websavages1 on Fri Jul 27, 2007 5:39 am

I tried both methods and agree that yours should give me what I need, however the email being received by the email client has the <?php echo $cf_id; ?> code (unparsed) in it.

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>      
<base href="http://www.xxxxxxxxxxxxx.au/" />
<style type="text/css">
</style>          
</head>
<body>
sfff has submitted the following High service request.<br />
sfff would like to instigate "fff" with the following scope:<br />
sddfs
<br />
<br />
and the reason for this is:<br />
fsdfsdsdfsd
<br />
<br />
This request was submitted on the 27th of July 2007 and has been
assigned as Service Request Number (SRN): <?php echo $cf_id; ?>
</body>
</html>


With the following as my email template

Code: Select all
{requestorName} has submitted the following {priority} service request.<br />
{requestorName} would like to instigate "{projectName}" with the following scope:<br />
{scope}
<br />
<br />
and the reason for this is:<br />
{benefit}
<br />
<br />
This request was submitted on the {date} and has been
assigned as Service Request Number (SRN): <?php echo $cf_id; ?>


Post edited by: websavages1, at: 2007/07/27 01:43

Post edited by: websavages1, at: 2007/07/27 01:44<br><br>Post edited by: websavages1, at: 2007/07/27 01:44
websavages1
Fresh Boarder
 
Posts: 9
Joined: Wed Jul 25, 2007 1:30 am

Re:Insert cf_id into the response email

Postby admin on Fri Jul 27, 2007 6:01 am

Hi websavages1,

Thats fine yes because the email template will be parsed as a string only, so basically I see no way to obtain the cf_id value in the email with the current release of CF, we plan a very soon release and I will really try to include this feature in it, how much time you can wait ?

Cheers

Max
ChronoForms Developer Thanks for using ChronoForms.
If you have any problems with ChronoForms please tell us.
If you like ChronoForms please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
User avatar
admin
Platinum Boarder
 
Posts: 2107
Joined: Mon Aug 14, 2006 5:29 am

Re:Insert cf_id into the response email

Postby GreyHead on Fri Jul 27, 2007 1:47 pm

Hi ws & Max,

Sorry, I didn't do enough checking. This does work with a template but you need an extra line.
Code: Select all
<?
$cf_id = 0;
$query = "SHOW TABLE STATUS LIKE 'jos_chronoforms_1'";
$result = mysql_query($query) or die ( "Query failed: " . mysql_error() . "
" . $query );
$row = mysql_fetch_assoc($result);
$cf_id = $row['Auto_increment'];
$html_message = str_replace( "#####", $cf_id, $html_message);
?>


If you put ##### in your template where you want the cf_id this will work. (I couldn't get it to work with '{cf_id}' as a marker though.)

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3251
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Insert cf_id into the response email

Postby websavages1 on Fri Jul 27, 2007 4:08 pm

How long can it wait, about five minutes longer than it will take you to announce a new release.

If you could include it that would be fantastic.

Cheers ws

Edit: Damn that's the second time I have replied to a post before I read all the replies. I will try the latest suggestion as per Bob's post (Dated 2007/07/27 09:47) My original statement above regarding Max's reply will also be valid.

Thanks to both of you for such a great effort.

Cheers ws<br><br>Post edited by: websavages1, at: 2007/07/27 12:12
websavages1
Fresh Boarder
 
Posts: 9
Joined: Wed Jul 25, 2007 1:30 am

Re:Insert cf_id into the response email

Postby websavages1 on Fri Aug 03, 2007 9:33 am

I have just implemented what Bob suggested and it works a charm. Thank you both.

Cheers ws
websavages1
Fresh Boarder
 
Posts: 9
Joined: Wed Jul 25, 2007 1:30 am

Next

Return to How To

Who is online

Users browsing this forum: No registered users and 7 guests