I need to transfer the submission ID to the client side after a webform is submitted. The problem is that after submission the Confirmation page is showed. And how can I attach the current sid to a page? I know how to do it on a node (se below) with Drupal behaviors on a client side JS-script.

Anyone? Or maybe the sid can be transfered to the client side another way?

function mymodule_webform_submission_insert($node, $submission) {
 // $node will give you the node id of your webform
 // $submission will give you the id of your data which you inserted in web form
 $sid = $submission->sid ? $submission->sid : FALSE;
   $currentSid = array('mymodule' => array('sid' => $sid));
   $node->content['#attached']['js'][] = array(
     'data' => $currentSid,
     'type' => 'setting',

You could start by putting the submission id into $_SESSION and add it to Drupal's js settings

drupal_add_js(array('mymodule' => array('webform_id' => $_SESSION['webform_id'])), 'setting');

Then access it on the client side

webform_id = Drupal.settings.mymodule.webform_id
| improve this answer | |
  • Thanks for your answer. Please bare with me, I can't get it to work. Where do I add the actual value of the submission ID in the key webform_id? – TBJ Apr 5 '17 at 7:21
  • Disregard the comment above. I am an idiot... Thanks again for the solution! – TBJ Apr 5 '17 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.