Extend the webform submission I am building a online purchasing system, and I use a Webform to gather clients' personal information.

A problem rises when I want to append some external data (which is not important enough to be included as a field in my registration form) to the webform before the submission.

What should I do? (I used hook_webform_submission_presave(), but it seems to me that it can only be used to change data, not adding additional data.)

Here's my presave hook; it works, but it's not serving my purpose.

function hook_webform_submission_presave($node, &amp;$submission) {
  // Update some component's value before it is saved.
  if ($node-&gt;nid == 0) {
      $component_id = 1;
      $submission-&gt;data[$component_id]['value'][0] = 'foo';
  }
}
You can't create a new value to non-existing field, since the data has no place to save to the database. Ideally you should create a hidden field for your data and modify it in your handler on presave event or use hook_ENTITY_TYPE_presave. If you have multiple values to add, serialize it or save into JSON and assign to the hidden value.

You can also use Computed token field where you can define and place your custom token (with any dynamic data) into value of that computed field which can fetch and store the data dynamically.

Related: Is there a webform way to store additional data on a submit handler?