Programatically get the webform submission "sid" on submitForm I am trying to programatically get the webform submission sid on submitting a webform but failed to get it !

On my customwebformhandler.php file i have the below:

public function submitForm(array &amp;$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
// Get an array of the values from the submission.
    $values = $webform_submission-&gt;getData();

    // Get the Webform submission "Sid".
    $sid = $webform_submission-&gt;id();

// Show a success message.
    \Drupal::messenger()-&gt;addMessage(t("$sid"));    

}


but i am not getting any sid value.

any help please ?
So it turns out i will have to save the webform before i can get its sid since i am using the public function submitForm which is fire in submitting the webform but before saving it.

Final code will be:

public function submitForm(array &amp;$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
// Get an array of the values from the submission.
    $values = $webform_submission-&gt;getData();
    // ...
    $webform_submission-&gt;save();

    // Get the Webform submission "Sid" after saving the webform submission.
    $sid = $webform_submission-&gt;id();

// Show a success message.
    \Drupal::messenger()-&gt;addMessage(t("$sid"));    

}