0

We have an aging D7 site that uses the Webform module to send emails to our organization's ServiceNow platform. The SN team wants to require the use of the SN API to process the webform submissions.

Is this even possible with D7? Webform only seems to sent emails via smtp, and the FAPI appears to only work on incoming/internal REST calls.

To be clear, we need to send REST calls from D

We're at least a year out from upgrading out of D7, so I have to work within its ecosphere.

1 Answer 1

1

I don't see a straight way of doing it, but here it is how I'd do it:

Are you familiar with Drupal hooks? That's the path I'd follow.

The Webform module has some hooks, I'd try with these 2:

  • hook_webform_submission_create_alter
  • hook_webform_submission_presave

Depending on your needs. Explore webform.api.php, inside the module's folder to see more details.

A simple and generic example:

Create a new module, let's say webform_mailing, then create a function that hooks into the Webform module, like this:

<?php

function webform_mailing_webform_submission_create_alter(&$submission, &$node, &$account, &$form_state) {
    // Do your API calls here
}

Your function will run when a Webform submission happens. You can then use the parameters, like the $submission to get the values, call your API and you're done!

Note: Be careful not modifying the $submission, as you see this value is passed by reference, so if you change it you can mess with your form submission data.

I hope this is helpful

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.