[Solved] receive the value of cf_id

loli 08 Jun, 2011
Hi,
in my email I wanted to receive the value of cf_id, I put in Step3 Design your Email(s): Id {cf_id}
but in my inbox I receive Id {cf_id} instead of the value of {cf_id}

Thank you for your help
GreyHead 08 Jun, 2011
Hi loli,

This is the cf_id from the saved record? And you are using ChronoForms v3.2?

This isn't available until after the data has been saved to the database and then you have to get the value from the saved data record.

The code you need is here:
<?php
$MyForm =& CFChronoForm::getInstance('my_form_name');
$cf_id = $MyForm->tablerow['jos_chronoforms_my_table_name']->cf_id;
echo $cf_id;
?>
It must go into the Email template - to do this you have to turn the Email Riche text editor off on the Email Properties box.

Then you must set the DB Connection to run Before Email.

Bob
loli 08 Jun, 2011

This is the cf_id from the saved record?


yes

And you are using ChronoForms v3.2?


yes

in Setup Email I put Use Template Editor:NO, I then paste the code in Emails Templates,
test after I received my mail in the following error:

Parse error: syntax error, unexpected '>' in /home/instantr/public_html/components/com_chronocontact/libraries/mails.php(98) : eval()'d code on line 5



Thank you
GreyHead 08 Jun, 2011
1 Likes
Hi loli,

Did you replace my_form_name and my_table_name with the names of your form and your table?

Bob
loli 08 Jun, 2011

Did you replace my_form_name and my_table_name with the names of your form and your table?


thank you very much it works
joomir 09 Jun, 2011
Hi,

thanks, i am using cf_id to show user ticket.
joomir 09 Jun, 2011
for getting cf_id i am using this code:


<?php

$db =& JFactory::getDBO();
$query = "SELECT * FROM Your_Table_Name order by cf_id DESC";
$db->setQuery($query);
$row = $db->loadRow();
echo($row[0]);
?>

in on submit code with custom action
GreyHead 09 Jun, 2011
Hi joomir,

That code is not entirely reliable. If two (or more) people are using the form at the same time then this may give you the incorrect value.

[list=a]
  • User 1 creates new record id = 100

  • User 2 creates new record id = 101

  • User 1 gets last record id = 101

  • User 2 gets last record id = 101
  • [/list:o]

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