1

I am Drupal beginner. I have created one webform with some fields (name, college, branch, address, email, contact number etc.). And when this form gets submitted I need to generate a unique registration number based on the selected college code and a serial number).

I also installed Webform Rules module but I don't understand how to achieve that.

Can anyone please help me to generate unique serial ID based on a field value during the Webform submission?

1

You can use webform hooks for add your custom code before sending the data or saving it into the database. Create hidden field in webform and set the value of the same using hook_webform_submission_presave For Ex.

function yourmodule_webform_submission_presave($node, &$submission) {
  // Update some component's value before it is saved.
  $component_id = 4; // where 4 is your hidden component id
  // Add your logic for registration code
  $submission->data[$component_id][0] = 'registration_code_you_wish_to_set';
}

Or If you want unique registration number check this module http://drupal.org/project/regcode

Hope this helps.

0

Every webform submission already has a unique submission id (SID). It is available via tokens. You can include it in your webform email notifications or use it in webform rules (on webform submit).

  • Good, but OP needs to have a specific college ID depending on some field value and a unique ID to be concatenated on submission. How can OP achieve that? – leymannx Jan 9 at 21:10

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.