how to access webform submission data from a custom content type

I ‘d be grateful if someone could help with this..

I have a webform, let’s call it input form, which, when submitted, triggers an external application to run on my server. That application uses some of the submission data (reading from webform_submission_data table) and after some time produces an output in the form of XML.

Now, through the use of feeds module, I read that XML data and produce a node, of a certain content type, let’s call it results CT ..

I have a twig template for the results content type, and output is nicely presented to the user.

So far, so good.

Now my problem is this. I need to show both input and output in the same results page.

I tried to use Webform Content Creator module and indeed I have nodes with submission data – let’s call this input data CT.

However, at the time of input form submission, I don’t have the results yet. And I want to link the two together, obviously upon the creation of the results node.

I tried to reference each content type, using Corresponding Entity References so that when a results node is created (automatically through feeds) it would link to the corresponding input data CT. I thought that if I can achieve that connection, then I would be able to access the ‘input’ data through the results page template.

However, I can’t make this connection to work – the ‘entity reference’ field that I use on the results CT, wants an ‘entity ID’ – and I can’t find that. Remember that nodes are created automatically, I don’t have a user creating nodes via a select form or autocomplete text field.

I am trying to figure out how to do this through the sid (submission id) which seems to be a unique key for every submission, and I have this on both my content types .. So ideally I would like to use the sid that I have on my results template, and use that to get the submission data I need.

(obviously) I am not very familiar with the drupal API – I am however comfortable with twig .. I don’t know if (and how) I could pass that information through a pre-process function to be available in the results template.. Is there a simpler way to do it?

Could I link two content types based on a custom field (say a unique number, like sid ??).

Ideally, in a few words, what I want is this:

I have a CT (results) with various fields, one of which is sid. That sid corresponds to a (unique) submission id. How can I access data relevant to that submission id from within the results twig template? So I can then present both input (submission data) and output (results) in the same page.

PS – Perhaps one solution would be to refactor the whole logic, and use one CT for both input/output. Insert some data upon form submission, and then, when results are ready, edit (i.e. fill-in) the rest of the ‘output’ fields via feeds. Then all data are in one CT. However I would rather avoid this as it’s quite a big change .. Shamefully enough, I might just re-enter input data through the XML again – it wouldn’t be a problem – but it’s a really crap solution ..

I ‘d be really grateful if someone could help .. I hope I explained the whole situation adequately enough ..

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

how to access webform submission data from a custom content type

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.