How to retrieve a webform submission data?

Created on 25 December 2023, 11 months ago
Updated 25 May 2024, 6 months ago

I am new to ECA as a result of disappointment to Rules For Drupal 10. I have troubles to understand how to retrieve Webform submission data.

I created a model called Take Notes, react on user submitted a webform. I need to retrieve the submission data. The event template I use is "Alter Submission Form", I am not sure whether it is the right one, but don't know which one is correctly reflecting "after a webform submitted". I also tried "Submission access", either of them let me define which webform in action. then I use Webform Submission: Get data, provide field name and everything, but nothing come out.

So is ECA webform ready For Drupal 10? How do I proceed from here>

Thank you for your help and advice!

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Postponed: needs info

Version

1.0

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sdsc
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    When a webform is being submitted, the submission data doesn't exist yet. The submitted data will be processed at that point and at the end of that process, a webform_submission entity will be created.

    So, if you want to do something with that data, you may want to start your ECA model with the Insert content entity event and configure that to work on the Webform Submission entity type. Then you can use the Webform Submission: Get data action to store the data into a token and then use that data there for further processing with other action plugins.

  • Thank you, jurgenhaas for your advice!

    I used your suggestion and put Insert content entity as event, the webform is configured on the content. I also inserted a display message of "starting..." right after this event, then I added template of Webform Submission: Get data, There are three custom fields:

    field name: I used "field_form_takenote", this is the field in parent content that referenced to the webform
    Name of token: I used "this_note_retrieved", this is the field name I think the webform data will be copied to.
    Entity: the webform name "takenote"

    Then I display the message: Hello! [this_note_retrieved:value]

    But nothing came out, no "starting..." either.

    I think I must have done something wrong. The three custom fields don't include the webform field name.

    Do you have any video demo of how to retrieve webform data?

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Your entity is the webform submission, not the node. And the action to get webform data is doing exactly that: it gives you access to the data in the webform submission, not in a node or anything else.

    That said, the Field name needs to be the name of a field as it appears in the webform. The Name of token should be a string for a name, under which you can later refer to when further processing the data you received. The field Entity can be left empty, as the entity in scope is the webform submission when you started the ECA model with Insert conten entity on a webform submission.

    When it comes to tokens, you may want to study this chapter of the ECA Guide: Tokens. It explains all of the context around tokens in ECA.

    You also seem to expect messages to be displayed like with ajax requests in the browser, where you can see something happening while the system works in the background. This is not what's going on here. When the user submits a webform, there is a request going to the server, and ECA is hooking into that process doing its work, together with all the other things Drupal is doing when a form gets submitted. When done, the user gets redirected to a page (configured in the webform), where Drupal displays all the messages that got created during that request. This is where messages issued by an ECA model will be displayed as well. But if an ECA model has errors or doesn't process for other reasons, i.e. that some given fields are not accessible or don't exist, then a model stops processing and subsequent actions don't get executed. That means also, that messages are not issued, if the ECA process doesn't get to that action.

  • πŸ‡ΊπŸ‡ΈUnited States dbdrupal

    Follow up on this, thanks for the description Jurgen. I'm able to make this work for fields on the Webform that are enterable (i.e. text box,etc ...). However, there are a few fields in my item webform that are item type fields (display only) and when I reference those in the Field Name, I'm unable to access them. Does this module only make available enterable fields? Follow up question ... can multiple fields be access in a single Get Data event or do I need to create an event for each field I want to read from the webform submission? Thanks!

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    @dbdrupal that would be a question to the webform maintainers. ECA is using a 1-liner to receive the data from the webform submission entity:

    $value = $webform_submission->getElementData($field_name);
    

    Not sure, if or why not this is returning values from non-input fields.

  • Status changed to Postponed: needs info 6 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
Production build 0.71.5 2024