Score:0

How to address the field value in a node from a webform

ru flag

I'm using Drupal 8 together with the Webform module.
Is there a way to transfer the value of a field in a specific content type to a webform?

This is the situation:
There's a content type called 'Vacature' where you create the specific content (vacancies). When adding a new vacancy I provide a field called 'vacaturecode' and a dropdown where you select the application webform that will be used to apply for the vacancy.

The application webform collects all the data of the applicant including two uploads (CV and motivation letter).
For these two upload fields I use the property 'File name pattern' to rename the original uploaded document to 00_lastname_CV_vacaturecode.pdf upon submission.

Therefore I use a string of tokens in the 'File name pattern' property: [webform_submission:serial]_[webform_submission:values:lastname]_CV_[webform_submission:node:field_vacaturecode:value]

This works, only I don't get to add the value of the field 'vacaturecode' that is submitted when creating the content. Instead the syntax is added as value.
I already tried various combinations of the syntax (e.g. [webform_submission:source-entity:entity:field_vacaturecode:value]) but I don't get it right.

Is there a way to address this value from within the webform?

Thanks for you help!

Score:0
ve flag

this sounds like a case for hook_webform_submission_presave. You can also see the available hooks here: http://api.drupalhelp.net/api/webform/webform_hooks.php/group/webform_hooks/6.3

You'll need to add the hook implementation to your theme or module file.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.