TOPIC:

Submitted form ID 2 weeks 2 days ago #245849

  • Topic Author
  • deeplogica
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 42
  • Thanks: 0
Hi
How can I get the submitted form ID in the Submitted Script? I need to perform some after submission SQL and need the ID of the form thats just been saved.

thanks

Please Log in or Create an account to join the conversation.

Submitted form ID 2 weeks 2 days ago #245852

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 644
  • Karma: 3
  • Thanks: 75
Hi,

Please try this:
1) Create hidden input and name it recordid
2) then go to your form->Advanced->more options->Form pieces->Before form->check custom and put this:
$this->execPieceByName('ff_InitLib');
$db =& JFactory::getDBO();

$result = null;
$query = "SELECT id
FROM #__facileforms_records
WHERE id = (SELECT MAX(id) FROM #__facileforms_records)";
$db->setQuery($query);
$result = $db->loadObject();

foreach($result as $a){
ff_setValue('recordid', $a);
}
3) go to your form->Advanced->more options->Scripts->Submitted Script->check custom and put this:
function ff_NAMEOFFORM_submitted(status, message)
{
    switch (status) {
        case FF_STATUS_OK:
           alert('The Record id is:' + ff_getElementByName('recordid').value);
           break;
        case FF_STATUS_UNPUBLISHED:
        case FF_STATUS_SAVERECORD_FAILED:
        case FF_STATUS_SAVESUBRECORD_FAILED:
        case FF_STATUS_UPLOAD_FAILED:
        case FF_STATUS_ATTACHMENT_FAILED:
        case FF_STATUS_SENDMAIL_FAILED:
        default:
           alert(message);
    } // switch
} // ff_NAMEOFFORM_submitted

Please replace NAMEOFFORM with name of your form.

Let me know if it works.

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Submitted form ID 2 weeks 2 days ago #245853

  • Topic Author
  • deeplogica
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 42
  • Thanks: 0
Hi
This would work for a submission, but what if someone else submits a form and saves before this one - I would then have the wrong ID.
Is there not a way to get the id from the table after its been submitted?
thanks

Please Log in or Create an account to join the conversation.

Submitted form ID 2 weeks 2 days ago #245858

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 644
  • Karma: 3
  • Thanks: 75
Hi,

then try this:
1) Go to your form->Advanced->more options->Submit pieces->End Submit pieces->check custom and put this:
$this->execPieceByName('ff_InitLib');
$db =& JFactory::getDBO();
$session = JFactory::getSession();


$query = 'SELECT MAX(id) FROM #__facileforms_records';
$db->setQuery($query);
$result = $db->loadResult();

$session->set('recordid', $result);

2) Go to your form->Advanced->more options->Form pieces->Before form -> check custom and put this:
$session = JFactory::getSession();
    
if (JRequest::getInt('ff_status', -1) == 0) {
$id = $session->get('r_id');    
echo 'Your record  id is: '.$id;
}

Let me know if it is ok for you


NOTE: Or try this Markus's suggestion

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Last edit: Post by tihana.krivic.

Submitted form ID 2 weeks 2 days ago #245859

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 9796
  • Karma: 167
  • Thanks: 785
You would basically put the first code snippet from Tihana in a submit piece => end submit

Please Log in or Create an account to join the conversation.

Submitted form ID 2 weeks 2 days ago #245860

  • Topic Author
  • deeplogica
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 42
  • Thanks: 0
Great, thanks to both of you.

cheers

Please Log in or Create an account to join the conversation.

Moderators: ForumSupport
Time to create page: 0.052 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

Summer Sale!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!